Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ internal static string GetOidFromHashAlgorithm(HashAlgorithmName algName)
return Oids.Sha384;
if (algName == HashAlgorithmName.SHA512)
return Oids.Sha512;
#if NET8_0_OR_GREATER
#if NET
if (algName == HashAlgorithmName.SHA3_256)
return Oids.Sha3_256;
if (algName == HashAlgorithmName.SHA3_384)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ public HuffmanDecodingException(string message)
{
}

#if NET8_0_OR_GREATER
#if NET
[Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
#endif
private HuffmanDecodingException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}

#if NET8_0_OR_GREATER
#if NET
[Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
#endif
void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
{
base.GetObjectData(serializationInfo, streamingContext);
}

#if NET8_0_OR_GREATER
#if NET
[Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public QPackDecodingException(string message, Exception innerException) : base(m
{
}

#if NET8_0_OR_GREATER
#if NET
[Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
#endif
private QPackDecodingException(SerializationInfo info, StreamingContext context) : base(info, context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public QPackEncodingException(string message, Exception innerException)
{
}

#if NET8_0_OR_GREATER
#if NET
[Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
#endif
private QPackEncodingException(SerializationInfo info, StreamingContext context) : base(info, context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public NetworkInformationException(int errorCode) : base(errorCode)
{
}

#if NET8_0_OR_GREATER
#if NET
[Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private static bool IsAttribute(string candidate, string attributeKind)

private static bool TryParseVersion(string attributeValue, ref Version? version)
{
#if NET8_0_OR_GREATER
#if NET
ReadOnlySpan<char> attributeValueSpan = attributeValue;
Span<Range> parts = stackalloc Range[5];
parts = parts.Slice(0, attributeValueSpan.Split(parts, '.'));
Expand All @@ -262,7 +262,7 @@ private static bool TryParseVersion(string attributeValue, ref Version? version)
for (int i = 0; i < parts.Length; i++)
{
if (!ushort.TryParse(
#if NET8_0_OR_GREATER
#if NET
attributeValueSpan[parts[i]],
#else
parts[i],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public WindowsCryptographicException(int hr, string message)
HResult = hr;
}

#if NET8_0_OR_GREATER
#if NET
[Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ private static void CheckHashAlgorithm(HashAlgorithmName hashAlgorithm)
case HashAlgorithmNames.SHA384:
case HashAlgorithmNames.SHA512:
break;
#if NET8_0_OR_GREATER
#if NET
case HashAlgorithmNames.SHA3_256:
if (!HMACSHA3_256.IsSupported)
{
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Common/tests/System/MockType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal class MockType : Type
public override bool IsSecurityCritical => throw Unexpected;
public override bool IsSecuritySafeCritical => throw Unexpected;
public override bool IsSecurityTransparent => throw Unexpected;
#if NET8_0_OR_GREATER
#if NET
[Obsolete("Formatter-based serialization is obsolete and should not be used.", DiagnosticId = "SYSLIB0050", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
#endif
public override bool IsSerializable => throw Unexpected;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public void SignPreHash_ThrowsForUnsupportedAlgorithmCombinations(MLDsaAlgorithm

protected static byte[]? CalculateMu(MLDsa mldsa, byte[] data, byte[]? context = null)
{
#if NET8_0_OR_GREATER
#if NET
if (MLDsaTestHelpers.ExternalMuIsSupported)
{
byte[] mu = new byte[mldsa.Algorithm.MuSizeInBytes];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static void EmptyTests(byte[] key, string label, string context, byte[] e
[InlineData(nameof(HashAlgorithmName.SHA512), 1024 / 8 - 1, new byte[] { 0xa4, 0xe5, 0x24, 0xe8, 0x56, 0x2b, 0x48, 0xa4 })]
[InlineData(nameof(HashAlgorithmName.SHA512), 1024 / 8, new byte[] { 0xba, 0xf6, 0xed, 0xa7, 0x3a, 0xf7, 0x12, 0x27 })]
[InlineData(nameof(HashAlgorithmName.SHA512), 1024 / 8 + 1, new byte[] { 0x34, 0xdf, 0x2d, 0x21, 0xfd, 0xf1, 0x0e, 0x13 })]
#if NET8_0_OR_GREATER
#if NET
[InlineData("SHA3-256", 1088 / 8 - 1, new byte[] { 0xa1, 0x96, 0xae, 0x83, 0x56, 0xf4, 0x2a, 0x4b })]
[InlineData("SHA3-256", 1088 / 8, new byte[] { 0xe7, 0xe9, 0xe0, 0x98, 0x09, 0x54, 0x54, 0x2d })]
[InlineData("SHA3-256", 1088 / 8 + 1, new byte[] { 0x7d, 0x7a, 0x71, 0xdf, 0x1f, 0x5d, 0x5b, 0x44 })]
Expand All @@ -108,7 +108,7 @@ public static void EmptyTests(byte[] key, string label, string context, byte[] e
#endif
public static void Kdk_HmacBlockBoundarySizes(string hashAlgorithmName, int kdkSize, byte[] expected)
{
#if NET8_0_OR_GREATER
#if NET
if ((hashAlgorithmName == "SHA3-256" && !SHA3_256.IsSupported) ||
(hashAlgorithmName == "SHA3-384" && !SHA3_384.IsSupported) ||
(hashAlgorithmName == "SHA3-512" && !SHA3_512.IsSupported))
Expand Down Expand Up @@ -328,7 +328,7 @@ public static IEnumerable<object[]> GetOutputLengthBoundaries()
}
};

#if NET8_0_OR_GREATER
#if NET
if (HMACSHA3_256.IsSupported)
{
// HMACSHA3_256 output size is 32 bytes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#if NET8_0_OR_GREATER
#if NET
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Cryptography.AesGcm))]
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Cryptography.AuthenticationTagMismatchException))]
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Security.Cryptography.SP800108HmacCounterKdf))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace System.Threading.Tasks
/// </remarks>
public static class TimeProviderTaskExtensions
{
#if !NET8_0_OR_GREATER
#if !NET
private sealed class DelayState : TaskCompletionSource<bool>
{
public DelayState(CancellationToken cancellationToken)
Expand All @@ -37,7 +37,7 @@ public WaitAsyncState(CancellationToken cancellationToken) : base(TaskCreationOp
public CancellationTokenRegistration Registration;
public ITimer? Timer;
}
#endif // !NET8_0_OR_GREATER
#endif // !NET

/// <summary>Creates a task that completes after a specified time interval.</summary>
/// <param name="timeProvider">The <see cref="TimeProvider"/> with which to interpret <paramref name="delay"/>.</param>
Expand All @@ -48,7 +48,7 @@ public WaitAsyncState(CancellationToken cancellationToken) : base(TaskCreationOp
/// <exception cref="System.ArgumentOutOfRangeException"><paramref name="delay"/> represents a negative time interval other than <see cref="Timeout.InfiniteTimeSpan"/>.</exception>
public static Task Delay(this TimeProvider timeProvider, TimeSpan delay, CancellationToken cancellationToken = default)
{
#if NET8_0_OR_GREATER
#if NET
return Task.Delay(delay, timeProvider, cancellationToken);
#else
if (timeProvider == TimeProvider.System)
Expand Down Expand Up @@ -114,7 +114,7 @@ public static Task Delay(this TimeProvider timeProvider, TimeSpan delay, Cancell
}

return state.Task;
#endif // NET8_0_OR_GREATER
#endif // NET
}

/// <summary>
Expand All @@ -129,7 +129,7 @@ public static Task Delay(this TimeProvider timeProvider, TimeSpan delay, Cancell
/// <exception cref="System.ArgumentOutOfRangeException"><paramref name="timeout"/> represents a negative time interval other than <see cref="Timeout.InfiniteTimeSpan"/>.</exception>
public static Task WaitAsync(this Task task, TimeSpan timeout, TimeProvider timeProvider, CancellationToken cancellationToken = default)
{
#if NET8_0_OR_GREATER
#if NET
return task.WaitAsync(timeout, timeProvider, cancellationToken);
#else
ArgumentNullException.ThrowIfNull(task);
Expand Down Expand Up @@ -204,7 +204,7 @@ public static Task WaitAsync(this Task task, TimeSpan timeout, TimeProvider time
}

return state.Task;
#endif // NET8_0_OR_GREATER
#endif // NET
}

/// <summary>
Expand All @@ -217,7 +217,7 @@ public static Task WaitAsync(this Task task, TimeSpan timeout, TimeProvider time
/// <returns>The <see cref="Task"/> representing the asynchronous wait. It may or may not be the same instance as the current instance.</returns>
/// <exception cref="System.ArgumentNullException"><paramref name="task"/> or <paramref name="timeProvider"/> is <see langword="null" />.</exception>
/// <exception cref="System.ArgumentOutOfRangeException"><paramref name="timeout"/> represents a negative time interval other than <see cref="Timeout.InfiniteTimeSpan"/>.</exception>
#if NET8_0_OR_GREATER
#if NET
public static Task<TResult> WaitAsync<TResult>(this Task<TResult> task, TimeSpan timeout, TimeProvider timeProvider, CancellationToken cancellationToken = default)
=> task.WaitAsync(timeout, timeProvider, cancellationToken);
#else
Expand All @@ -226,7 +226,7 @@ public static async Task<TResult> WaitAsync<TResult>(this Task<TResult> task, Ti
await ((Task)task).WaitAsync(timeout, timeProvider, cancellationToken).ConfigureAwait(false);
return task.Result;
}
#endif // NET8_0_OR_GREATER
#endif // NET

/// <summary>Initializes a new instance of the <see cref="CancellationTokenSource"/> class that will be canceled after the specified <see cref="TimeSpan"/>. </summary>
/// <param name="timeProvider">The <see cref="TimeProvider"/> with which to interpret the <paramref name="delay"/>. </param>
Expand All @@ -246,7 +246,7 @@ public static async Task<TResult> WaitAsync<TResult>(this Task<TResult> task, Ti
/// </remarks>
public static CancellationTokenSource CreateCancellationTokenSource(this TimeProvider timeProvider, TimeSpan delay)
{
#if NET8_0_OR_GREATER
#if NET
return new CancellationTokenSource(delay, timeProvider);
#else
ArgumentNullException.ThrowIfNull(timeProvider);
Expand Down Expand Up @@ -274,7 +274,7 @@ public static CancellationTokenSource CreateCancellationTokenSource(this TimePro

cts.Token.Register(static t => ((ITimer)t!).Dispose(), timer);
return cts;
#endif // NET8_0_OR_GREATER
#endif // NET
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private static char[] GetInvalidFileNameChars() => Path.GetInvalidFileNameChars(
private static char[] GetInvalidFilterChars() => GetInvalidFileNameChars()
.Where(c => c != '*' && c != '|' && c != '?').ToArray();

#if NET8_0_OR_GREATER
#if NET
private static readonly SearchValues<char> _invalidFileNameChars = SearchValues.Create(GetInvalidFileNameChars());
private static readonly SearchValues<char> _invalidFilterChars = SearchValues.Create(GetInvalidFilterChars());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public virtual async Task StopAsync(CancellationToken cancellationToken)
}
finally
{
#if NET8_0_OR_GREATER
#if NET
await _executeTask.WaitAsync(cancellationToken).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
#else
// Wait until the task completes or the stop token triggers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.Extensions.Hosting
[Serializable]
public sealed class HostAbortedException : Exception
{
#if NET8_0_OR_GREATER
#if NET
[Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
#endif
private HostAbortedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static async Task WaitForShutdownAsync(this IHost host, CancellationToken
},
applicationLifetime);

#if NET8_0_OR_GREATER
#if NET
await Task.Delay(Timeout.Infinite, applicationLifetime.ApplicationStopping).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
#else
var waitForStop = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static IServiceCollection AddHttpClient(this IServiceCollection services)

services.AddLogging();
services.AddOptions();
#if NET8_0_OR_GREATER
#if NET
services.AddMetrics();
#endif

Expand All @@ -51,7 +51,7 @@ public static IServiceCollection AddHttpClient(this IServiceCollection services)
// Misc infrastructure
//
services.TryAddEnumerable(ServiceDescriptor.Singleton<IHttpMessageHandlerBuilderFilter, LoggingHttpMessageHandlerBuilderFilter>());
#if NET8_0_OR_GREATER
#if NET
services.TryAddEnumerable(ServiceDescriptor.Singleton<IHttpMessageHandlerBuilderFilter, MetricsFactoryHttpMessageHandlerFilter>());
#endif

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#if NET8_0_OR_GREATER
#if NET
using System;
using System.Diagnostics.Metrics;
using System.Net.Http;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Microsoft.Extensions.Http
{
#if NET8_0_OR_GREATER
#if NET
public class MeterFactoryIntegrationTest
{
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBrowser))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal sealed class LogValuesFormatter
{
private const string NullValue = "(null)";
private readonly List<string> _valueNames = new List<string>();
#if NET8_0_OR_GREATER
#if NET
private readonly CompositeFormat _format;
#else
private readonly string _format;
Expand All @@ -44,7 +44,7 @@ public LogValuesFormatter(string format)
{
// No holes found.
_format =
#if NET8_0_OR_GREATER
#if NET
CompositeFormat.Parse(format);
#else
format;
Expand Down Expand Up @@ -75,7 +75,7 @@ public LogValuesFormatter(string format)
}

_format =
#if NET8_0_OR_GREATER
#if NET
CompositeFormat.Parse(vsb.ToString());
#else
vsb.ToString();
Expand Down Expand Up @@ -176,14 +176,14 @@ internal string FormatWithOverwrite(object?[]? values)

internal string Format()
{
#if NET8_0_OR_GREATER
#if NET
return _format.Format;
#else
return _format;
#endif
}

#if NET8_0_OR_GREATER
#if NET
internal string Format<TArg0>(TArg0 arg0)
{
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,7 @@ public sealed partial class OptionsUsingGeneratedAttributesValidator : IValidate
string generatedSource = File.ReadAllText(languageVersion == LanguageVersion.CSharp10 ? @"Baselines/GeneratedAttributesTest.netcore.lang10.g.cs" : @"Baselines/GeneratedAttributesTest.netcore.lang11.g.cs");
#else
string generatedSource = File.ReadAllText(languageVersion == LanguageVersion.CSharp10 ? @"Baselines/GeneratedAttributesTest.netfx.lang10.g.cs" : @"Baselines/GeneratedAttributesTest.netfx.lang11.g.cs");
#endif // NET8_0_OR_GREATER
#endif // NET
Assert.Equal(generatedSource.Replace("\r\n", "\n"), emittedSource.Replace("\r\n", "\n"));

CSharpCompilation compilation = CreateCompilationForOptionsSource(Path.GetRandomFileName(), source + emittedSource, refAssemblyPath: null, languageVersion);
Expand Down
Loading
Loading