diff --git a/src/libraries/Common/src/Internal/Cryptography/PkcsHelpers.cs b/src/libraries/Common/src/Internal/Cryptography/PkcsHelpers.cs index 10bc0179aff2cf..ea4d04400092c3 100644 --- a/src/libraries/Common/src/Internal/Cryptography/PkcsHelpers.cs +++ b/src/libraries/Common/src/Internal/Cryptography/PkcsHelpers.cs @@ -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) diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HuffmanDecodingException.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HuffmanDecodingException.cs index b83ca6502e8c55..0b8fd7c43272d6 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HuffmanDecodingException.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http2/Hpack/HuffmanDecodingException.cs @@ -19,7 +19,7 @@ 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) @@ -27,7 +27,7 @@ private HuffmanDecodingException(SerializationInfo info, StreamingContext contex { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] #endif void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) @@ -35,7 +35,7 @@ void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingC base.GetObjectData(serializationInfo, streamingContext); } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackDecodingException.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackDecodingException.cs index 5de0efff935d4f..2b51589573396c 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackDecodingException.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackDecodingException.cs @@ -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) diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackEncodingException.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackEncodingException.cs index 7e6eb6f1b79280..e60c60e951a24d 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackEncodingException.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackEncodingException.cs @@ -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) diff --git a/src/libraries/Common/src/System/Net/NetworkInformation/NetworkInformationException.cs b/src/libraries/Common/src/System/Net/NetworkInformation/NetworkInformationException.cs index 14d23cad452391..8503810bfa5abd 100644 --- a/src/libraries/Common/src/System/Net/NetworkInformation/NetworkInformationException.cs +++ b/src/libraries/Common/src/System/Net/NetworkInformation/NetworkInformationException.cs @@ -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 diff --git a/src/libraries/Common/src/System/Reflection/AssemblyNameParser.cs b/src/libraries/Common/src/System/Reflection/AssemblyNameParser.cs index 5e60f0d5badf2d..162c2273392321 100644 --- a/src/libraries/Common/src/System/Reflection/AssemblyNameParser.cs +++ b/src/libraries/Common/src/System/Reflection/AssemblyNameParser.cs @@ -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 attributeValueSpan = attributeValue; Span parts = stackalloc Range[5]; parts = parts.Slice(0, attributeValueSpan.Split(parts, '.')); @@ -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], diff --git a/src/libraries/Common/src/System/Security/Cryptography/CryptoThrowHelper.Windows.cs b/src/libraries/Common/src/System/Security/Cryptography/CryptoThrowHelper.Windows.cs index e7cd24e0eeb1f8..5e6aadd44137df 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/CryptoThrowHelper.Windows.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/CryptoThrowHelper.Windows.cs @@ -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 diff --git a/src/libraries/Common/src/System/Security/Cryptography/SP800108HmacCounterKdf.cs b/src/libraries/Common/src/System/Security/Cryptography/SP800108HmacCounterKdf.cs index 523f99be26051b..6ad21f7528bff5 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/SP800108HmacCounterKdf.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/SP800108HmacCounterKdf.cs @@ -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) { diff --git a/src/libraries/Common/tests/System/MockType.cs b/src/libraries/Common/tests/System/MockType.cs index 4de0fed4077d1d..0e0870140a306a 100644 --- a/src/libraries/Common/tests/System/MockType.cs +++ b/src/libraries/Common/tests/System/MockType.cs @@ -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; diff --git a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsBase.cs b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsBase.cs index 7ef071a2d1b86d..b39a30a6baf554 100644 --- a/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsBase.cs +++ b/src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsBase.cs @@ -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]; diff --git a/src/libraries/Common/tests/System/Security/Cryptography/SP800108HmacCounterKdfTests.Functional.cs b/src/libraries/Common/tests/System/Security/Cryptography/SP800108HmacCounterKdfTests.Functional.cs index 5eb6d097026c65..31191e4164195c 100644 --- a/src/libraries/Common/tests/System/Security/Cryptography/SP800108HmacCounterKdfTests.Functional.cs +++ b/src/libraries/Common/tests/System/Security/Cryptography/SP800108HmacCounterKdfTests.Functional.cs @@ -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 })] @@ -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)) @@ -328,7 +328,7 @@ public static IEnumerable GetOutputLengthBoundaries() } }; -#if NET8_0_OR_GREATER +#if NET if (HMACSHA3_256.IsSupported) { // HMACSHA3_256 output size is 32 bytes diff --git a/src/libraries/Microsoft.Bcl.Cryptography/src/Microsoft.Bcl.Cryptography.Forwards.cs b/src/libraries/Microsoft.Bcl.Cryptography/src/Microsoft.Bcl.Cryptography.Forwards.cs index 38be9698441d88..7718316a03710a 100644 --- a/src/libraries/Microsoft.Bcl.Cryptography/src/Microsoft.Bcl.Cryptography.Forwards.cs +++ b/src/libraries/Microsoft.Bcl.Cryptography/src/Microsoft.Bcl.Cryptography.Forwards.cs @@ -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))] diff --git a/src/libraries/Microsoft.Bcl.TimeProvider/src/System/Threading/Tasks/TimeProviderTaskExtensions.cs b/src/libraries/Microsoft.Bcl.TimeProvider/src/System/Threading/Tasks/TimeProviderTaskExtensions.cs index 6274bab9a02c75..1376e63cc011d5 100644 --- a/src/libraries/Microsoft.Bcl.TimeProvider/src/System/Threading/Tasks/TimeProviderTaskExtensions.cs +++ b/src/libraries/Microsoft.Bcl.TimeProvider/src/System/Threading/Tasks/TimeProviderTaskExtensions.cs @@ -12,7 +12,7 @@ namespace System.Threading.Tasks /// public static class TimeProviderTaskExtensions { -#if !NET8_0_OR_GREATER +#if !NET private sealed class DelayState : TaskCompletionSource { public DelayState(CancellationToken cancellationToken) @@ -37,7 +37,7 @@ public WaitAsyncState(CancellationToken cancellationToken) : base(TaskCreationOp public CancellationTokenRegistration Registration; public ITimer? Timer; } -#endif // !NET8_0_OR_GREATER +#endif // !NET /// Creates a task that completes after a specified time interval. /// The with which to interpret . @@ -48,7 +48,7 @@ public WaitAsyncState(CancellationToken cancellationToken) : base(TaskCreationOp /// represents a negative time interval other than . 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) @@ -114,7 +114,7 @@ public static Task Delay(this TimeProvider timeProvider, TimeSpan delay, Cancell } return state.Task; -#endif // NET8_0_OR_GREATER +#endif // NET } /// @@ -129,7 +129,7 @@ public static Task Delay(this TimeProvider timeProvider, TimeSpan delay, Cancell /// represents a negative time interval other than . 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); @@ -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 } /// @@ -217,7 +217,7 @@ public static Task WaitAsync(this Task task, TimeSpan timeout, TimeProvider time /// The representing the asynchronous wait. It may or may not be the same instance as the current instance. /// or is . /// represents a negative time interval other than . -#if NET8_0_OR_GREATER +#if NET public static Task WaitAsync(this Task task, TimeSpan timeout, TimeProvider timeProvider, CancellationToken cancellationToken = default) => task.WaitAsync(timeout, timeProvider, cancellationToken); #else @@ -226,7 +226,7 @@ public static async Task WaitAsync(this Task task, Ti await ((Task)task).WaitAsync(timeout, timeProvider, cancellationToken).ConfigureAwait(false); return task.Result; } -#endif // NET8_0_OR_GREATER +#endif // NET /// Initializes a new instance of the class that will be canceled after the specified . /// The with which to interpret the . @@ -246,7 +246,7 @@ public static async Task WaitAsync(this Task task, Ti /// 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); @@ -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 } } } diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Internal/PathUtils.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Internal/PathUtils.cs index 02bc4d5f6acf41..9b075731b7721f 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Internal/PathUtils.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Internal/PathUtils.cs @@ -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 _invalidFileNameChars = SearchValues.Create(GetInvalidFileNameChars()); private static readonly SearchValues _invalidFilterChars = SearchValues.Create(GetInvalidFilterChars()); diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs index f2d1cea2fb25ad..7eb877cba2ec03 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs @@ -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 diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostAbortedException.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostAbortedException.cs index 7b3184a882eeba..3ff9010b8cc21e 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostAbortedException.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostAbortedException.cs @@ -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) { } diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostExtensions.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostExtensions.cs index f5ee438a2a74cf..a57792c8b02fc6 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostExtensions.cs @@ -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(TaskCreationOptions.RunContinuationsAsynchronously); diff --git a/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/HttpClientFactoryServiceCollectionExtensions.cs b/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/HttpClientFactoryServiceCollectionExtensions.cs index 154d05b7254b6b..3ba6f5736fc8de 100644 --- a/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/HttpClientFactoryServiceCollectionExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/HttpClientFactoryServiceCollectionExtensions.cs @@ -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 @@ -51,7 +51,7 @@ public static IServiceCollection AddHttpClient(this IServiceCollection services) // Misc infrastructure // services.TryAddEnumerable(ServiceDescriptor.Singleton()); -#if NET8_0_OR_GREATER +#if NET services.TryAddEnumerable(ServiceDescriptor.Singleton()); #endif diff --git a/src/libraries/Microsoft.Extensions.Http/src/MetricsFactoryHttpMessageHandlerFilter.cs b/src/libraries/Microsoft.Extensions.Http/src/MetricsFactoryHttpMessageHandlerFilter.cs index 2a8645b09cb3f6..9b806062e5b932 100644 --- a/src/libraries/Microsoft.Extensions.Http/src/MetricsFactoryHttpMessageHandlerFilter.cs +++ b/src/libraries/Microsoft.Extensions.Http/src/MetricsFactoryHttpMessageHandlerFilter.cs @@ -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; diff --git a/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/MeterFactoryIntegrationTest.cs b/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/MeterFactoryIntegrationTest.cs index a685fb7d8050ff..04cbaff60ed47a 100644 --- a/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/MeterFactoryIntegrationTest.cs +++ b/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/MeterFactoryIntegrationTest.cs @@ -9,7 +9,7 @@ namespace Microsoft.Extensions.Http { -#if NET8_0_OR_GREATER +#if NET public class MeterFactoryIntegrationTest { [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBrowser))] diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogValuesFormatter.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogValuesFormatter.cs index 44951b8c84c931..0be51e2b067fff 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogValuesFormatter.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogValuesFormatter.cs @@ -17,7 +17,7 @@ internal sealed class LogValuesFormatter { private const string NullValue = "(null)"; private readonly List _valueNames = new List(); -#if NET8_0_OR_GREATER +#if NET private readonly CompositeFormat _format; #else private readonly string _format; @@ -44,7 +44,7 @@ public LogValuesFormatter(string format) { // No holes found. _format = -#if NET8_0_OR_GREATER +#if NET CompositeFormat.Parse(format); #else format; @@ -75,7 +75,7 @@ public LogValuesFormatter(string format) } _format = -#if NET8_0_OR_GREATER +#if NET CompositeFormat.Parse(vsb.ToString()); #else vsb.ToString(); @@ -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 arg0) { return diff --git a/src/libraries/Microsoft.Extensions.Options/tests/SourceGeneration.Unit.Tests/Main.cs b/src/libraries/Microsoft.Extensions.Options/tests/SourceGeneration.Unit.Tests/Main.cs index f55323caeedc14..ae0a282934ee2b 100644 --- a/src/libraries/Microsoft.Extensions.Options/tests/SourceGeneration.Unit.Tests/Main.cs +++ b/src/libraries/Microsoft.Extensions.Options/tests/SourceGeneration.Unit.Tests/Main.cs @@ -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); diff --git a/src/libraries/Microsoft.Extensions.Options/tests/SourceGeneration.Unit.Tests/OptionsRuntimeTests.cs b/src/libraries/Microsoft.Extensions.Options/tests/SourceGeneration.Unit.Tests/OptionsRuntimeTests.cs index 761a765752f5f6..736f8251b6bd60 100644 --- a/src/libraries/Microsoft.Extensions.Options/tests/SourceGeneration.Unit.Tests/OptionsRuntimeTests.cs +++ b/src/libraries/Microsoft.Extensions.Options/tests/SourceGeneration.Unit.Tests/OptionsRuntimeTests.cs @@ -238,7 +238,7 @@ public void TestValidationWithCyclicReferences() Assert.True(result1.Succeeded); } -#if NET8_0_OR_GREATER +#if NET [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBrowser))] public void TestNewDataAnnotationFailures() { @@ -267,14 +267,14 @@ public void TestNewDataAnnotationFailures() "P5: The OptionsUsingNewAttributes.P5 field equals one of the values specified in DeniedValuesAttribute." }, result.Failures); } -#endif // NET8_0_OR_GREATER +#endif // NET [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBrowser))] public void TestCustomGeneratedAttributes() { OptionsUsingGeneratedAttributes noFailures = new OptionsUsingGeneratedAttributes() { -#if NET8_0_OR_GREATER +#if NET P0 = "123", P11 = new DateTime(2023, 2, 1), P12 = 6, @@ -295,7 +295,7 @@ public void TestCustomGeneratedAttributes() P30 = new HashSet { "1", "2", "3" }, P31 = new List { 1, 2, 3, 4 }, P32 = new HashSet { 1, 2, 3, 4 }, -#endif // NET8_0_OR_GREATER +#endif // NET P1 = 2, P2 = "12345", P3 = "12345", @@ -318,7 +318,7 @@ public void TestCustomGeneratedAttributes() OptionsUsingGeneratedAttributes failing = new OptionsUsingGeneratedAttributes() { -#if NET8_0_OR_GREATER +#if NET P0 = "", P11 = new DateTime(2023, 1, 1), P12 = 5, @@ -339,7 +339,7 @@ public void TestCustomGeneratedAttributes() P30 = new HashSet { "1", "2" }, P31 = new List { 1, 2, 3, 4, 5 }, P32 = new HashSet { 1, 2, 3, 4, 5 }, -#endif // NET8_0_OR_GREATER +#endif // NET P1 = 4, P2 = "1234", P3 = "123456", @@ -361,7 +361,7 @@ public void TestCustomGeneratedAttributes() Assert.True(generatorResult.Failed); Assert.Equal(new [] { -#if NET8_0_OR_GREATER +#if NET "P0: The field OptionsUsingGeneratedAttributes.P0 must be a string or collection type with a minimum length of '1' and maximum length of '3'.", string.Format(CultureInfo.CurrentCulture, "P11: The field OptionsUsingGeneratedAttributes.P11 must be between {0} and {1}.", new DateTime(2023, 1, 30), new DateTime(2023, 12, 30)), "P12: The field OptionsUsingGeneratedAttributes.P12 must be between 5 exclusive and 10.", @@ -382,7 +382,7 @@ public void TestCustomGeneratedAttributes() "P30: The field OptionsUsingGeneratedAttributes.P30 must be a string or array type with a minimum length of '3'.", "P31: The field OptionsUsingGeneratedAttributes.P31 must be a string or array type with a maximum length of '4'.", "P32: The field OptionsUsingGeneratedAttributes.P32 must be a string or array type with a maximum length of '4'.", -#endif // NET8_0_OR_GREATER +#endif // NET "P1: The field OptionsUsingGeneratedAttributes.P1 must be between 1 and 3.", "P2: The field OptionsUsingGeneratedAttributes.P2 must be a string or array type with a minimum length of '5'.", "P3: The field OptionsUsingGeneratedAttributes.P3 must be a string or array type with a maximum length of '5'.", @@ -424,7 +424,7 @@ public class FakeCountChild(int count) : FakeCount(count) { } public class OptionsUsingGeneratedAttributes { -#if NET8_0_OR_GREATER +#if NET [LengthAttribute(1, 3)] public string? P0 { get; set; } @@ -487,7 +487,7 @@ public class OptionsUsingGeneratedAttributes [MaxLengthAttribute(4)] public ICollection P32 { get; set; } -#endif // NET8_0_OR_GREATER +#endif // NET [RangeAttribute(1, 3)] public int P1 { get; set; } @@ -598,7 +598,7 @@ public class MyDictionaryOptions : Dictionary { [Required] publi public class MyListOptions : List { [Required] public T Prop { get; set; } = default; } [OptionsValidator] public partial class MyListOptionsOptionsValidator : IValidateOptions> { } -#if NET8_0_OR_GREATER +#if NET public class OptionsUsingNewAttributes { [Length(5, 10)] @@ -621,7 +621,7 @@ public class OptionsUsingNewAttributes public partial class NewAttributesValidator : IValidateOptions { } -#endif // NET8_0_OR_GREATER +#endif // NET public class OptionsWithTimeSpanRangeAttribute diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/KeyAnalyzer.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/KeyAnalyzer.cs index 0793b3d12f7315..198b3459655df1 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/KeyAnalyzer.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/KeyAnalyzer.cs @@ -4,7 +4,7 @@ using System.Buffers; using System.Collections.Generic; using System.Diagnostics; -#if !NET8_0_OR_GREATER +#if !NET using System.Runtime.CompilerServices; #endif @@ -201,7 +201,7 @@ private static bool AreAllAscii(ReadOnlySpan strings) internal static unsafe bool IsAllAscii(ReadOnlySpan s) { -#if NET8_0_OR_GREATER +#if NET return System.Text.Ascii.IsValid(s); #else fixed (char* src = s) @@ -238,14 +238,14 @@ internal static unsafe bool IsAllAscii(ReadOnlySpan s) #endif } -#if NET8_0_OR_GREATER +#if NET private static readonly SearchValues s_asciiLetters = SearchValues.Create("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); #endif internal static bool ContainsAnyAsciiLetters(ReadOnlySpan s) { Debug.Assert(IsAllAscii(s)); -#if NET8_0_OR_GREATER +#if NET return s.ContainsAny(s_asciiLetters); #else foreach (char c in s) diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.cs index b6f3bf81b0f105..902e9168872cf4 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedSet_1.cs @@ -1191,7 +1191,7 @@ private ImmutableSortedSet LeafToRootRefill(ReadOnlySpan addedItems) list = new List(this.Count + addedItems.Length); list.AddRange(this); } -#if NET8_0_OR_GREATER +#if NET list.AddRange(addedItems); #else foreach (var item in addedItems) diff --git a/src/libraries/System.ComponentModel.Composition/ref/System.ComponentModel.Composition.cs b/src/libraries/System.ComponentModel.Composition/ref/System.ComponentModel.Composition.cs index b9528f89e7a02b..c51c8bb868c7d8 100644 --- a/src/libraries/System.ComponentModel.Composition/ref/System.ComponentModel.Composition.cs +++ b/src/libraries/System.ComponentModel.Composition/ref/System.ComponentModel.Composition.cs @@ -55,7 +55,7 @@ public ChangeRejectedException(string? message, System.Exception? innerException public partial class CompositionContractMismatchException : System.Exception { public CompositionContractMismatchException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -145,7 +145,7 @@ public ImportAttribute(System.Type? contractType) { } public partial class ImportCardinalityMismatchException : System.Exception { public ImportCardinalityMismatchException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -543,7 +543,7 @@ protected ComposablePartDefinition() { } public partial class ComposablePartException : System.Exception { public ComposablePartException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -553,7 +553,7 @@ public ComposablePartException(string? message, System.ComponentModel.Compositio public ComposablePartException(string? message, System.ComponentModel.Composition.Primitives.ICompositionElement? element, System.Exception? innerException) { } public ComposablePartException(string? message, System.Exception? innerException) { } public System.ComponentModel.Composition.Primitives.ICompositionElement? Element { get { throw null; } } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/CompositionContractMismatchException.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/CompositionContractMismatchException.cs index 73b8f0b233529c..7109705145af1c 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/CompositionContractMismatchException.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/CompositionContractMismatchException.cs @@ -77,7 +77,7 @@ public CompositionContractMismatchException(string? message, Exception? innerExc /// /// contains a value that cannot be cast to the correct type. /// -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ImportCardinalityMismatchException.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ImportCardinalityMismatchException.cs index 898934ac298a25..2439528becb040 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ImportCardinalityMismatchException.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ImportCardinalityMismatchException.cs @@ -80,7 +80,7 @@ public ImportCardinalityMismatchException(string? message, Exception? innerExcep /// /// contains a value that cannot be cast to the correct type. /// -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartException.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartException.cs index 95a0369cd02024..fe9ba3ae4b8236 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartException.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartException.cs @@ -47,7 +47,7 @@ public ComposablePartException() /// /// contains a value that cannot be cast to the correct type. /// -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -164,7 +164,7 @@ public ICompositionElement? Element /// /// is . /// -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Configuration.ConfigurationManager/ref/System.Configuration.ConfigurationManager.cs b/src/libraries/System.Configuration.ConfigurationManager/ref/System.Configuration.ConfigurationManager.cs index c8eaba8e10509a..7c5d7ed0ac0b91 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/ref/System.Configuration.ConfigurationManager.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/ref/System.Configuration.ConfigurationManager.cs @@ -267,7 +267,7 @@ public ConfigurationElementProperty(System.Configuration.ConfigurationValidatorB public partial class ConfigurationErrorsException : System.Configuration.ConfigurationException { public ConfigurationErrorsException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -289,7 +289,7 @@ public ConfigurationErrorsException(string message, System.Xml.XmlReader reader) public static string GetFilename(System.Xml.XmlReader reader) { throw null; } public static int GetLineNumber(System.Xml.XmlNode node) { throw null; } public static int GetLineNumber(System.Xml.XmlReader reader) { throw null; } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -299,7 +299,7 @@ public partial class ConfigurationException : System.SystemException { [System.ObsoleteAttribute("ConfigurationException has been deprecated. Use System.Configuration.ConfigurationErrorsException instead.")] public ConfigurationException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -320,7 +320,7 @@ public ConfigurationException(string message, System.Xml.XmlNode node) { } public virtual string Filename { get { throw null; } } public virtual int Line { get { throw null; } } public override string Message { get { throw null; } } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -470,7 +470,7 @@ public void CopyTo(System.Configuration.ConfigurationSection[] array, int index) public System.Configuration.ConfigurationSection Get(string name) { throw null; } public override System.Collections.IEnumerator GetEnumerator() { throw null; } public string GetKey(int index) { throw null; } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -506,7 +506,7 @@ public void CopyTo(System.Configuration.ConfigurationSectionGroup[] array, int i public System.Configuration.ConfigurationSectionGroup Get(string name) { throw null; } public override System.Collections.IEnumerator GetEnumerator() { throw null; } public string GetKey(int index) { throw null; } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -887,7 +887,7 @@ internal PropertyInformationCollection() { } public System.Configuration.PropertyInformation this[string propertyName] { get { throw null; } } public void CopyTo(System.Configuration.PropertyInformation[] array, int index) { } public override System.Collections.IEnumerator GetEnumerator() { throw null; } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -1173,7 +1173,7 @@ public void SetReadOnly() { } public partial class SettingsPropertyIsReadOnlyException : System.Exception { public SettingsPropertyIsReadOnlyException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -1184,7 +1184,7 @@ public SettingsPropertyIsReadOnlyException(string message, System.Exception inne public partial class SettingsPropertyNotFoundException : System.Exception { public SettingsPropertyNotFoundException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -1221,7 +1221,7 @@ public void SetReadOnly() { } public partial class SettingsPropertyWrongTypeException : System.Exception { public SettingsPropertyWrongTypeException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -1610,7 +1610,7 @@ void System.Collections.ICollection.CopyTo(System.Array array, int index) { } public partial class ProviderException : System.Exception { public ProviderException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs index f72769050e5134..276da625a9626e 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs @@ -19,7 +19,7 @@ namespace System.Configuration [DebuggerDisplay("ConfigPath = {ConfigPath}")] internal abstract class BaseConfigurationRecord : IInternalConfigRecord { -#if NET8_0_OR_GREATER +#if NET private static readonly SearchValues s_invalidSubPathChars = SearchValues.Create(InvalidSubPathCharactersString); #else private static ReadOnlySpan s_invalidSubPathChars => InvalidSubPathCharactersString.AsSpan(); diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationErrorsException.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationErrorsException.cs index e78b7ecbd7fa78..315582fcde4192 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationErrorsException.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationErrorsException.cs @@ -101,7 +101,7 @@ internal ConfigurationErrorsException(ArrayList coll) : coll.CopyTo(_errors, 0); } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -196,7 +196,7 @@ private static ConfigurationException GetFirstException(ICollection [Event(19, Keywords = Keywords.TimeSeriesValues, Version = 1)] -#if !NET8_0_OR_GREATER +#if !NET [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "This calls WriteEvent with all primitive arguments which is safe. Primitives are always serialized properly.")] #endif diff --git a/src/libraries/System.Diagnostics.EventLog/ref/System.Diagnostics.EventLog.cs b/src/libraries/System.Diagnostics.EventLog/ref/System.Diagnostics.EventLog.cs index 007bd0b4c2eff9..4a1404af7248e8 100644 --- a/src/libraries/System.Diagnostics.EventLog/ref/System.Diagnostics.EventLog.cs +++ b/src/libraries/System.Diagnostics.EventLog/ref/System.Diagnostics.EventLog.cs @@ -227,7 +227,7 @@ public partial class EventLogException : System.Exception { public EventLogException() { } protected EventLogException(int errorCode) { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -235,7 +235,7 @@ protected EventLogException(System.Runtime.Serialization.SerializationInfo seria public EventLogException(string message) { } public EventLogException(string message, System.Exception innerException) { } public override string Message { get { throw null; } } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -256,7 +256,7 @@ internal EventLogInformation() { } public partial class EventLogInvalidDataException : System.Diagnostics.Eventing.Reader.EventLogException { public EventLogInvalidDataException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -286,7 +286,7 @@ public enum EventLogMode public partial class EventLogNotFoundException : System.Diagnostics.Eventing.Reader.EventLogException { public EventLogNotFoundException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -303,7 +303,7 @@ protected virtual void Dispose(bool disposing) { } public partial class EventLogProviderDisabledException : System.Diagnostics.Eventing.Reader.EventLogException { public EventLogProviderDisabledException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -339,7 +339,7 @@ public void Seek(System.IO.SeekOrigin origin, long offset) { } public partial class EventLogReadingException : System.Diagnostics.Eventing.Reader.EventLogException { public EventLogReadingException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogException.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogException.cs index cd1e3e2e4631ec..4de5abf9f0fee1 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogException.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogException.cs @@ -68,7 +68,7 @@ public override string Message private readonly int _errorCode; -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -78,7 +78,7 @@ protected EventLogException(SerializationInfo serializationInfo, StreamingContex _errorCode = serializationInfo.GetInt32("errorCode"); } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -99,7 +99,7 @@ public EventLogNotFoundException() { } public EventLogNotFoundException(string message) : base(message) { } public EventLogNotFoundException(string message, Exception innerException) : base(message, innerException) { } internal EventLogNotFoundException(int errorCode) : base(errorCode) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -118,7 +118,7 @@ public EventLogReadingException() { } public EventLogReadingException(string message) : base(message) { } public EventLogReadingException(string message, Exception innerException) : base(message, innerException) { } internal EventLogReadingException(int errorCode) : base(errorCode) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -137,7 +137,7 @@ public EventLogProviderDisabledException() { } public EventLogProviderDisabledException(string message) : base(message) { } public EventLogProviderDisabledException(string message, Exception innerException) : base(message, innerException) { } internal EventLogProviderDisabledException(int errorCode) : base(errorCode) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -154,7 +154,7 @@ public EventLogInvalidDataException() { } public EventLogInvalidDataException(string message) : base(message) { } public EventLogInvalidDataException(string message, Exception innerException) : base(message, innerException) { } internal EventLogInvalidDataException(int errorCode) : base(errorCode) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.DirectoryServices.AccountManagement/ref/System.DirectoryServices.AccountManagement.cs b/src/libraries/System.DirectoryServices.AccountManagement/ref/System.DirectoryServices.AccountManagement.cs index 4f7382064d92da..f495f8490f293f 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/ref/System.DirectoryServices.AccountManagement.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/ref/System.DirectoryServices.AccountManagement.cs @@ -151,7 +151,7 @@ public enum MatchType public partial class MultipleMatchesException : System.DirectoryServices.AccountManagement.PrincipalException { public MultipleMatchesException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -162,7 +162,7 @@ public MultipleMatchesException(string message, System.Exception innerException) public partial class NoMatchingPrincipalException : System.DirectoryServices.AccountManagement.PrincipalException { public NoMatchingPrincipalException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -173,7 +173,7 @@ public NoMatchingPrincipalException(string message, System.Exception innerExcept public partial class PasswordException : System.DirectoryServices.AccountManagement.PrincipalException { public PasswordException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -276,7 +276,7 @@ public void Dispose() { } public abstract partial class PrincipalException : System.SystemException { private protected PrincipalException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -285,7 +285,7 @@ protected PrincipalException(System.Runtime.Serialization.SerializationInfo info public partial class PrincipalExistsException : System.DirectoryServices.AccountManagement.PrincipalException { public PrincipalExistsException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -296,7 +296,7 @@ public PrincipalExistsException(string message, System.Exception innerException) public partial class PrincipalOperationException : System.DirectoryServices.AccountManagement.PrincipalException { public PrincipalOperationException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -306,7 +306,7 @@ public PrincipalOperationException(string message, System.Exception innerExcepti public PrincipalOperationException(string message, System.Exception innerException, int errorCode) { } public PrincipalOperationException(string message, int errorCode) { } public int ErrorCode { get { throw null; } } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -334,7 +334,7 @@ public void Dispose() { } public partial class PrincipalServerDownException : System.DirectoryServices.AccountManagement.PrincipalException { public PrincipalServerDownException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -344,7 +344,7 @@ public PrincipalServerDownException(string message, System.Exception innerExcept public PrincipalServerDownException(string message, System.Exception innerException, int errorCode) { } public PrincipalServerDownException(string message, System.Exception innerException, int errorCode, string serverName) { } public PrincipalServerDownException(string message, int errorCode) { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs index 93fe9c7dd24b5a..920b3495dacce0 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs @@ -23,7 +23,7 @@ internal PrincipalException(string message, Exception innerException) : base(message, innerException) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -45,7 +45,7 @@ public MultipleMatchesException(string message, Exception innerException) : base(message, innerException) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -67,7 +67,7 @@ public NoMatchingPrincipalException(string message, Exception innerException) : base(message, innerException) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -89,7 +89,7 @@ public PasswordException(string message, Exception innerException) : base(message, innerException) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -111,7 +111,7 @@ public PrincipalExistsException(string message, Exception innerException) : base(message, innerException) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -150,7 +150,7 @@ public PrincipalServerDownException(string message, Exception innerException, in _serverName = serverName; } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -161,7 +161,7 @@ protected PrincipalServerDownException(SerializationInfo info, StreamingContext _serverName = (string)info.GetValue("serverName", typeof(string)); } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -196,7 +196,7 @@ public PrincipalOperationException(string message, Exception innerException, int _errorCode = errorCode; } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -206,7 +206,7 @@ protected PrincipalOperationException(SerializationInfo info, StreamingContext c _errorCode = info.GetInt32("errorCode"); } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.DirectoryServices.Protocols/ref/System.DirectoryServices.Protocols.cs b/src/libraries/System.DirectoryServices.Protocols/ref/System.DirectoryServices.Protocols.cs index 0c08b61ae5681f..1ccbb5c2c4916f 100644 --- a/src/libraries/System.DirectoryServices.Protocols/ref/System.DirectoryServices.Protocols.cs +++ b/src/libraries/System.DirectoryServices.Protocols/ref/System.DirectoryServices.Protocols.cs @@ -46,7 +46,7 @@ public enum AuthType public partial class BerConversionException : System.DirectoryServices.Protocols.DirectoryException { public BerConversionException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -194,7 +194,7 @@ public void Remove(System.DirectoryServices.Protocols.DirectoryControl value) { public partial class DirectoryException : System.Exception { public DirectoryException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -220,7 +220,7 @@ public DirectoryOperationException() { } public DirectoryOperationException(System.DirectoryServices.Protocols.DirectoryResponse response) { } public DirectoryOperationException(System.DirectoryServices.Protocols.DirectoryResponse response, string message) { } public DirectoryOperationException(System.DirectoryServices.Protocols.DirectoryResponse response, string message, System.Exception inner) { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -228,7 +228,7 @@ protected DirectoryOperationException(System.Runtime.Serialization.Serialization public DirectoryOperationException(string message) { } public DirectoryOperationException(string message, System.Exception inner) { } public System.DirectoryServices.Protocols.DirectoryResponse Response { get { throw null; } } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -361,7 +361,7 @@ public LdapException(int errorCode) { } public LdapException(int errorCode, string message) { } public LdapException(int errorCode, string message, System.Exception inner) { } public LdapException(int errorCode, string message, string serverErrorMessage) { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -371,7 +371,7 @@ public LdapException(string message, System.Exception inner) { } public int ErrorCode { get { throw null; } } public System.DirectoryServices.Protocols.PartialResultsCollection PartialResults { get { throw null; } } public string ServerErrorMessage { get { throw null; } } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -735,7 +735,7 @@ public TlsOperationException() { } public TlsOperationException(System.DirectoryServices.Protocols.DirectoryResponse response) { } public TlsOperationException(System.DirectoryServices.Protocols.DirectoryResponse response, string message) { } public TlsOperationException(System.DirectoryServices.Protocols.DirectoryResponse response, string message, System.Exception inner) { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs index 48235f0cbc1ef5..dc325aa4c2238f 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryException.cs @@ -11,7 +11,7 @@ namespace System.DirectoryServices.Protocols [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public class DirectoryException : Exception { -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -36,7 +36,7 @@ public DirectoryException() : base() [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public class DirectoryOperationException : DirectoryException, ISerializable { -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -83,7 +83,7 @@ private static string CreateMessage(DirectoryResponse response, string? message) [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public class BerConversionException : DirectoryException { -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapException.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapException.cs index 6c972a875df33d..b98ac407223b4a 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapException.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapException.cs @@ -93,7 +93,7 @@ public class LdapException : DirectoryException, ISerializable { private int _errorCode; -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -145,7 +145,7 @@ private set [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public class TlsOperationException : DirectoryOperationException { -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.DirectoryServices/ref/System.DirectoryServices.cs b/src/libraries/System.DirectoryServices/ref/System.DirectoryServices.cs index 718084c2a9d79d..c4631c89137c77 100644 --- a/src/libraries/System.DirectoryServices/ref/System.DirectoryServices.cs +++ b/src/libraries/System.DirectoryServices/ref/System.DirectoryServices.cs @@ -255,7 +255,7 @@ protected override void Dispose(bool disposing) { } public partial class DirectoryServicesCOMException : System.Runtime.InteropServices.COMException, System.Runtime.Serialization.ISerializable { public DirectoryServicesCOMException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -264,7 +264,7 @@ public DirectoryServicesCOMException(string? message) { } public DirectoryServicesCOMException(string? message, System.Exception? inner) { } public int ExtendedError { get { throw null; } } public string? ExtendedErrorMessage { get { throw null; } } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -539,7 +539,7 @@ public void Save() { } public partial class ActiveDirectoryObjectExistsException : System.Exception { public ActiveDirectoryObjectExistsException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -550,7 +550,7 @@ public ActiveDirectoryObjectExistsException(string? message, System.Exception? i public partial class ActiveDirectoryObjectNotFoundException : System.Exception, System.Runtime.Serialization.ISerializable { public ActiveDirectoryObjectNotFoundException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -560,7 +560,7 @@ public ActiveDirectoryObjectNotFoundException(string? message, System.Exception? public ActiveDirectoryObjectNotFoundException(string? message, System.Type? type, string? name) { } public string? Name { get { throw null; } } public System.Type? Type { get { throw null; } } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -569,7 +569,7 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf public partial class ActiveDirectoryOperationException : System.Exception, System.Runtime.Serialization.ISerializable { public ActiveDirectoryOperationException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -579,7 +579,7 @@ public ActiveDirectoryOperationException(string? message, System.Exception? inne public ActiveDirectoryOperationException(string? message, System.Exception? inner, int errorCode) { } public ActiveDirectoryOperationException(string? message, int errorCode) { } public int ErrorCode { get { throw null; } } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -743,7 +743,7 @@ public void Remove(System.DirectoryServices.ActiveDirectory.ActiveDirectorySchem public partial class ActiveDirectoryServerDownException : System.Exception, System.Runtime.Serialization.ISerializable { public ActiveDirectoryServerDownException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -755,7 +755,7 @@ public ActiveDirectoryServerDownException(string? message, int errorCode, string public int ErrorCode { get { throw null; } } public override string Message { get { throw null; } } public string? Name { get { throw null; } } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -1311,7 +1311,7 @@ public enum ForestMode public partial class ForestTrustCollisionException : System.DirectoryServices.ActiveDirectory.ActiveDirectoryOperationException, System.Runtime.Serialization.ISerializable { public ForestTrustCollisionException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -1320,7 +1320,7 @@ public ForestTrustCollisionException(string? message) { } public ForestTrustCollisionException(string? message, System.Exception? inner) { } public ForestTrustCollisionException(string? message, System.Exception? inner, System.DirectoryServices.ActiveDirectory.ForestTrustRelationshipCollisionCollection? collisions) { } public System.DirectoryServices.ActiveDirectory.ForestTrustRelationshipCollisionCollection? Collisions { get { throw null; } } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -1703,7 +1703,7 @@ public enum SyncFromAllServersEvent public partial class SyncFromAllServersOperationException : System.DirectoryServices.ActiveDirectory.ActiveDirectoryOperationException, System.Runtime.Serialization.ISerializable { public SyncFromAllServersOperationException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -1712,7 +1712,7 @@ public SyncFromAllServersOperationException(string? message) { } public SyncFromAllServersOperationException(string? message, System.Exception? inner) { } public SyncFromAllServersOperationException(string? message, System.Exception? inner, System.DirectoryServices.ActiveDirectory.SyncFromAllServersErrorInformation[]? errors) { } public System.DirectoryServices.ActiveDirectory.SyncFromAllServersErrorInformation[] ErrorInformation { get { throw null; } } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs index 85ea36b623f06a..4a2c0b69a9ab57 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs @@ -47,7 +47,7 @@ public ActiveDirectoryObjectNotFoundException(string? message) : base(message) { public ActiveDirectoryObjectNotFoundException() : base() { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -59,7 +59,7 @@ protected ActiveDirectoryObjectNotFoundException(SerializationInfo info, Streami public string? Name { get; } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -103,7 +103,7 @@ public ActiveDirectoryOperationException(string? message) : base(message ?? SR.D public ActiveDirectoryOperationException() : base(SR.DSUnknownFailure) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -113,7 +113,7 @@ protected ActiveDirectoryOperationException(SerializationInfo info, StreamingCon public int ErrorCode { get; } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -145,7 +145,7 @@ public ActiveDirectoryServerDownException(string? message) : base(message) { } public ActiveDirectoryServerDownException() : base() { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -170,7 +170,7 @@ public override string Message } } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -190,7 +190,7 @@ public ActiveDirectoryObjectExistsException(string? message) : base(message) { } public ActiveDirectoryObjectExistsException() : base() { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -216,7 +216,7 @@ public SyncFromAllServersOperationException(string? message) : base(message ?? S public SyncFromAllServersOperationException() : base(SR.DSSyncAllFailure) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -239,7 +239,7 @@ public SyncFromAllServersErrorInformation[] ErrorInformation } } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -264,7 +264,7 @@ public ForestTrustCollisionException(string? message) : base(message ?? SR.Fores public ForestTrustCollisionException() : base(SR.ForestTrustCollision) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -274,7 +274,7 @@ protected ForestTrustCollisionException(SerializationInfo info, StreamingContext public ForestTrustRelationshipCollisionCollection? Collisions { get; } = new ForestTrustRelationshipCollisionCollection(); -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/TrustHelper.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/TrustHelper.cs index 6591d54f956ea2..9d4d86d6438dd7 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/TrustHelper.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/TrustHelper.cs @@ -910,7 +910,7 @@ private static void ValidateTrustAttribute(Interop.Advapi32.TRUSTED_DOMAIN_INFOR internal static string CreateTrustPassword() { -#if NET8_0_OR_GREATER +#if NET return RandomNumberGenerator.GetString(PasswordCharacterSet, PASSWORD_LENGTH); #else char[] cBuf = new char[PASSWORD_LENGTH]; diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryServicesCOMException.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryServicesCOMException.cs index 4afcf03e7a834e..311200a1b6d535 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryServicesCOMException.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryServicesCOMException.cs @@ -17,7 +17,7 @@ public DirectoryServicesCOMException(string? message) : base(message) { } public DirectoryServicesCOMException(string? message, Exception? inner) : base(message, inner) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -35,7 +35,7 @@ internal DirectoryServicesCOMException(string? extendedMessage, int extendedErro public string? ExtendedErrorMessage { get; } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Formats.Asn1/ref/System.Formats.Asn1.cs b/src/libraries/System.Formats.Asn1/ref/System.Formats.Asn1.cs index 4e6516e80b9ca4..eeb4e1a85a9c63 100644 --- a/src/libraries/System.Formats.Asn1/ref/System.Formats.Asn1.cs +++ b/src/libraries/System.Formats.Asn1/ref/System.Formats.Asn1.cs @@ -45,7 +45,7 @@ namespace System.Formats.Asn1 public partial class AsnContentException : System.Exception { public AsnContentException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnContentException.cs b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnContentException.cs index 782c86ea766738..b35d0ce2b49c3e 100644 --- a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnContentException.cs +++ b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnContentException.cs @@ -55,7 +55,7 @@ public AsnContentException(string? message, Exception? inner) /// /// The contextual information about the source or destination. /// -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.Text.cs b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.Text.cs index 3f65857b997369..6aebb2aed8bbc9 100644 --- a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.Text.cs +++ b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.Text.cs @@ -392,7 +392,7 @@ private static unsafe bool TryReadCharacterStringCore( { try { -#if NET8_0_OR_GREATER +#if NET return encoding.TryGetChars(source, destination, out charsWritten); #else if (source.Length == 0) diff --git a/src/libraries/System.Formats.Cbor/ref/System.Formats.Cbor.cs b/src/libraries/System.Formats.Cbor/ref/System.Formats.Cbor.cs index f5c698a1d17e26..d4f52fc0e0ffed 100644 --- a/src/libraries/System.Formats.Cbor/ref/System.Formats.Cbor.cs +++ b/src/libraries/System.Formats.Cbor/ref/System.Formats.Cbor.cs @@ -15,7 +15,7 @@ public enum CborConformanceMode } public partial class CborContentException : System.Exception { -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/CborContentException.cs b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/CborContentException.cs index 68f606dac4e7f0..adaeaca66640cf 100644 --- a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/CborContentException.cs +++ b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/CborContentException.cs @@ -37,7 +37,7 @@ public CborContentException(string? message, Exception? inner) /// /// The object that holds the serialized object data. /// The contextual information about the source or destination. -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.Tag.cs b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.Tag.cs index 3ca04f085e04c0..245c5eb0d3f458 100644 --- a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.Tag.cs +++ b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.Tag.cs @@ -38,11 +38,11 @@ public void WriteTag(CborTag tag) public void WriteDateTimeOffset(DateTimeOffset value) { string dateString = -#if NET8_0_OR_GREATER +#if NET value.TotalOffsetMinutes == 0 ? #else value.Offset == TimeSpan.Zero ? -#endif // NET8_0_OR_GREATER +#endif // NET value.UtcDateTime.ToString(Rfc3339FormatString, CultureInfo.InvariantCulture) : // prefer 'Z' over '+00:00' value.ToString(Rfc3339FormatString, CultureInfo.InvariantCulture); diff --git a/src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/ArrayInfo.cs b/src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/ArrayInfo.cs index da03a459f35aa9..dd045f7cd9e483 100644 --- a/src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/ArrayInfo.cs +++ b/src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/ArrayInfo.cs @@ -16,7 +16,7 @@ namespace System.Formats.Nrbf; [DebuggerDisplay("{ArrayType}, rank={Rank}")] internal readonly struct ArrayInfo { -#if NET8_0_OR_GREATER +#if NET internal static int MaxArrayLength => Array.MaxLength; // dynamic lookup in case the value changes in a future runtime #else internal const int MaxArrayLength = 2147483591; // hardcode legacy Array.MaxLength for downlevel runtimes diff --git a/src/libraries/System.IO.Packaging/ref/System.IO.Packaging.Serialization.cs b/src/libraries/System.IO.Packaging/ref/System.IO.Packaging.Serialization.cs index 58a03be2fa2f60..2d61730d20c73d 100644 --- a/src/libraries/System.IO.Packaging/ref/System.IO.Packaging.Serialization.cs +++ b/src/libraries/System.IO.Packaging/ref/System.IO.Packaging.Serialization.cs @@ -8,12 +8,12 @@ namespace System.IO { public partial class FileFormatException : System.FormatException { -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif protected FileFormatException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs index 9946c94badff4d..426277a101add5 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/FileFormatException.cs @@ -113,7 +113,7 @@ public FileFormatException(Uri? sourceUri, string? message, Exception? innerExce _sourceUri = sourceUri; } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -129,7 +129,7 @@ protected FileFormatException(SerializationInfo info, StreamingContext context) /// /// The object that holds the serialized object data. /// The contextual information about the source or destination. -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Management/ref/System.Management.cs b/src/libraries/System.Management/ref/System.Management.cs index a7c68e9ce52f14..d9d5e673eefb23 100644 --- a/src/libraries/System.Management/ref/System.Management.cs +++ b/src/libraries/System.Management/ref/System.Management.cs @@ -136,7 +136,7 @@ public InvokeMethodOptions(System.Management.ManagementNamedValueCollection cont public partial class ManagementBaseObject : System.ComponentModel.Component, System.ICloneable, System.Runtime.Serialization.ISerializable { private protected ManagementBaseObject() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -168,7 +168,7 @@ public ManagementClass() { } public ManagementClass(System.Management.ManagementPath path) { } public ManagementClass(System.Management.ManagementPath path, System.Management.ObjectGetOptions options) { } public ManagementClass(System.Management.ManagementScope scope, System.Management.ManagementPath path, System.Management.ObjectGetOptions options) { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -242,7 +242,7 @@ public void Stop() { } public partial class ManagementException : System.SystemException { public ManagementException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -251,7 +251,7 @@ public ManagementException(string message) { } public ManagementException(string message, System.Exception innerException) { } public System.Management.ManagementStatus ErrorCode { get { throw null; } } public System.Management.ManagementBaseObject ErrorInformation { get { throw null; } } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -260,7 +260,7 @@ public override void GetObjectData(System.Runtime.Serialization.SerializationInf public partial class ManagementNamedValueCollection : System.Collections.Specialized.NameObjectCollectionBase { public ManagementNamedValueCollection() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -277,7 +277,7 @@ public ManagementObject() { } public ManagementObject(System.Management.ManagementPath path) { } public ManagementObject(System.Management.ManagementPath path, System.Management.ObjectGetOptions options) { } public ManagementObject(System.Management.ManagementScope scope, System.Management.ManagementPath path, System.Management.ObjectGetOptions options) { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Management/src/System/Management/ManagementBaseObject.cs b/src/libraries/System.Management/src/System/Management/ManagementBaseObject.cs index 0da42a48cedbbb..76a77643843a8f 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementBaseObject.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementBaseObject.cs @@ -223,7 +223,7 @@ internal IWbemClassObjectFreeThreaded wbemObject /// /// The to populate with data. /// The destination (see ) for this serialization. -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Management/src/System/Management/ManagementClass.cs b/src/libraries/System.Management/src/System/Management/ManagementClass.cs index 96806c56afed32..0d33a6e0465813 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementClass.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementClass.cs @@ -267,7 +267,7 @@ public ManagementClass(ManagementScope scope, ManagementPath path, ObjectGetOpti public ManagementClass(string scope, string path, ObjectGetOptions options) : base(new ManagementScope(scope), new ManagementPath(path), options) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Management/src/System/Management/ManagementException.cs b/src/libraries/System.Management/src/System/Management/ManagementException.cs index d2dc99a119d061..10c1e7cbf4fdb2 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementException.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementException.cs @@ -672,7 +672,7 @@ internal ManagementException(Exception e, string msg, ManagementBaseObject errOb /// /// The to populate with data. /// The destination (see ) for this serialization. -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -720,7 +720,7 @@ public ManagementException(string message, Exception innerException) : this(inne /// /// The to populate with data. /// The destination (see ) for this serialization. -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Management/src/System/Management/ManagementNamedValueCollection.cs b/src/libraries/System.Management/src/System/Management/ManagementNamedValueCollection.cs index 68efddb9bdae59..d6aae5e686cf60 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementNamedValueCollection.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementNamedValueCollection.cs @@ -46,7 +46,7 @@ public ManagementNamedValueCollection() /// /// The to populate with data. /// The destination (see ) for this serialization. -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Management/src/System/Management/ManagementObject.cs b/src/libraries/System.Management/src/System/Management/ManagementObject.cs index 3030400ac54ff9..6686227dd59890 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementObject.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementObject.cs @@ -462,7 +462,7 @@ public ManagementObject(string scopeString, string pathString, ObjectGetOptions /// /// The to populate with data. /// The destination (see ) for this serialization. -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpException.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpException.cs index fb017ebe43612d..22e7caa9256b3c 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpException.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpException.cs @@ -17,7 +17,7 @@ public WinHttpException(int error, string message) : base(error, message) this.HResult = ConvertErrorCodeToHR(error); } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/CollectionHelpers.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/CollectionHelpers.cs index d3b9f1f19f5275..9495033ac3b3f1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/CollectionHelpers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/CollectionHelpers.cs @@ -9,7 +9,7 @@ internal static class CollectionHelpers { internal static void ValidateCopyToArguments(int sourceCount, Array array, int index) { -#if NET8_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(array); #else ArgumentNullException.ThrowIfNull(array); @@ -25,7 +25,7 @@ internal static void ValidateCopyToArguments(int sourceCount, Array array, int i throw new ArgumentException(SR.Arg_NonZeroLowerBound, nameof(array)); } -#if NET8_0_OR_GREATER +#if NET ArgumentOutOfRangeException.ThrowIfNegative(index); ArgumentOutOfRangeException.ThrowIfGreaterThan(index, array.Length); #else diff --git a/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Delegation/DelegatingType.cs b/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Delegation/DelegatingType.cs index bd7ef3ff90eaeb..379312698c3415 100644 --- a/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Delegation/DelegatingType.cs +++ b/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Delegation/DelegatingType.cs @@ -109,7 +109,7 @@ public override bool IsSecurityTransparent get { return _typeInfo.IsSecurityTransparent; } } -#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 diff --git a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.Manual.cs b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.Manual.cs index 17093fb7e92161..e3c07e81e46b39 100644 --- a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.Manual.cs +++ b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.Manual.cs @@ -16,7 +16,7 @@ public readonly partial struct AssemblyReference } public partial class ImageFormatLimitationException : System.Exception { -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/AssemblyNameInfo.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/AssemblyNameInfo.cs index 23edc3dde0048e..ed71d26c08a2d2 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/AssemblyNameInfo.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/AssemblyNameInfo.cs @@ -60,7 +60,7 @@ internal AssemblyNameInfo(AssemblyNameParser.AssemblyNameParts parts) #else PublicKeyOrToken = parts._publicKeyOrToken is null ? default : parts._publicKeyOrToken.Length == 0 ? ImmutableArray.Empty - #if NET8_0_OR_GREATER + #if NET : Runtime.InteropServices.ImmutableCollectionsMarshal.AsImmutableArray(parts._publicKeyOrToken); #else : ImmutableArray.Create(parts._publicKeyOrToken); @@ -134,7 +134,7 @@ internal void AppendFullName(ref ValueStringBuilder vsb) byte[]? publicKeyOrToken = #if SYSTEM_PRIVATE_CORELIB PublicKeyOrToken; -#elif NET8_0_OR_GREATER +#elif NET !PublicKeyOrToken.IsDefault ? Runtime.InteropServices.ImmutableCollectionsMarshal.AsArray(PublicKeyOrToken) : null; #else !PublicKeyOrToken.IsDefault ? PublicKeyOrToken.ToArray() : null; diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/ImageFormatLimitationException.Serialization.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/ImageFormatLimitationException.Serialization.cs index ed6b2ab3e8eab8..10fc4899ac6f27 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/ImageFormatLimitationException.Serialization.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/ImageFormatLimitationException.Serialization.cs @@ -10,7 +10,7 @@ namespace System.Reflection.Metadata [Serializable] public partial class ImageFormatLimitationException : Exception { -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Internal/NamespaceCache.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Internal/NamespaceCache.cs index 6eddeadf9a5177..dbb85c1b56c6b7 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Internal/NamespaceCache.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Internal/NamespaceCache.cs @@ -207,7 +207,7 @@ private NamespaceDataBuilder SynthesizeNamespaceData(string fullName, NamespaceD { Debug.Assert(realChild.HasFullName); -#if NET8_0_OR_GREATER +#if NET int numberOfSegments = fullName.AsSpan().Count('.'); #else int numberOfSegments = 0; diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeNameParserHelpers.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeNameParserHelpers.cs index 7428d05a39e22e..6772d490257486 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeNameParserHelpers.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeNameParserHelpers.cs @@ -15,7 +15,7 @@ internal static class TypeNameParserHelpers internal const int Pointer = -2; internal const int ByRef = -3; private const char EscapeCharacter = '\\'; -#if NET8_0_OR_GREATER +#if NET // Keep this in sync with GetFullTypeNameLength/NeedsEscaping private static readonly SearchValues s_endOfFullTypeNameDelimitersSearchValues = SearchValues.Create("[]&*,+\\"); #endif @@ -36,7 +36,7 @@ internal static int GetFullTypeNameLength(ReadOnlySpan input, out bool isN // input, that makes the total loop complexity potentially O(m * n^2), where // 'n' is adversary-controlled. To avoid DoS issues here, we'll loop manually. -#if NET8_0_OR_GREATER +#if NET int offset = input.IndexOfAny(s_endOfFullTypeNameDelimitersSearchValues); if (offset < 0) { diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeNameParserOptions.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeNameParserOptions.cs index 53d6f7f164275a..a15da53a5109da 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeNameParserOptions.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeNameParserOptions.cs @@ -22,7 +22,7 @@ public int MaxNodes get => _maxNodes; set { -#if NET8_0_OR_GREATER +#if NET ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(value, 0, nameof(value)); #else if (value <= 0) diff --git a/src/libraries/System.Reflection.Metadata/tests/Metadata/TypeNameTests.cs b/src/libraries/System.Reflection.Metadata/tests/Metadata/TypeNameTests.cs index abd0ec87059f7d..23e999955b3e49 100644 --- a/src/libraries/System.Reflection.Metadata/tests/Metadata/TypeNameTests.cs +++ b/src/libraries/System.Reflection.Metadata/tests/Metadata/TypeNameTests.cs @@ -942,7 +942,7 @@ static void Verify(Type type, TypeName typeName, bool ignoreCase) } } -#if NET8_0_OR_GREATER +#if NET [RequiresUnreferencedCode("The type might be removed")] [RequiresDynamicCode("Required by MakeArrayType")] #else diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/RoAssembly.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/RoAssembly.cs index 05acfef523df4b..f67400930ece39 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/RoAssembly.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Assemblies/RoAssembly.cs @@ -194,7 +194,7 @@ public sealed override AssemblyName[] GetReferencedAssemblies() } // Serialization -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Helpers.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Helpers.cs index 60263a0c6516f6..638a47e9bae1a6 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Helpers.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Helpers.cs @@ -12,7 +12,7 @@ namespace System.Reflection.TypeLoading { internal static class Helpers { -#if NET8_0_OR_GREATER +#if NET private static readonly SearchValues s_charsToEscape = SearchValues.Create("\\[]+*&,"); #else private static ReadOnlySpan s_charsToEscape => "\\[]+*&,".AsSpan(); @@ -125,7 +125,7 @@ public static bool TypeNameContainsTypeParserMetacharacters(this string identifi public static bool NeedsEscapingInTypeName(this char c) { -#if NET8_0_OR_GREATER +#if NET return s_charsToEscape.Contains(c); #else return s_charsToEscape.IndexOf(c) >= 0; diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/RoModule.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/RoModule.cs index f236b209b3d25f..7a2982e7cb0733 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/RoModule.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/RoModule.cs @@ -72,7 +72,7 @@ public sealed override string Name public abstract override MethodInfo[] GetMethods(BindingFlags bindingFlags); protected abstract override MethodInfo? GetMethodImpl(string name, BindingFlags bindingAttr, Binder? binder, CallingConventions callConvention, Type[]? types, ParameterModifier[]? modifiers); -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/TestUtils/TestUtils.JittedRuntimes.cs b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/TestUtils/TestUtils.JittedRuntimes.cs index d483dd47c3c511..a92eb322b851df 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/TestUtils/TestUtils.JittedRuntimes.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/TestUtils/TestUtils.JittedRuntimes.cs @@ -16,7 +16,7 @@ public static Type Project(this Type type) if (type == null) return null; -#if NET8_0_OR_GREATER +#if NET // Function pointers don't support Type.GetType() so they can't be dynamically created. if (type.IsFunctionPointer) throw new NotSupportedException("Function pointers don't support Project()"); diff --git a/src/libraries/System.Runtime.Serialization.Xml/tests/SerializationTypes.RuntimeOnly.cs b/src/libraries/System.Runtime.Serialization.Xml/tests/SerializationTypes.RuntimeOnly.cs index 1e09b903fa7e1b..a79c8f5bab2058 100644 --- a/src/libraries/System.Runtime.Serialization.Xml/tests/SerializationTypes.RuntimeOnly.cs +++ b/src/libraries/System.Runtime.Serialization.Xml/tests/SerializationTypes.RuntimeOnly.cs @@ -4315,7 +4315,7 @@ public MyArgumentException(string message, string paramName) : base(message) _paramName = paramName; } -#if NET8_0_OR_GREATER +#if NET [Obsolete("Exception..ctor(SerializationInfo, StreamingContext) is obsolete.", DiagnosticId = "SYSLIB0051")] #endif protected MyArgumentException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -4334,7 +4334,7 @@ internal set } } -#if NET8_0_OR_GREATER +#if NET [Obsolete("Exception.GetObjectData is obsolete.", DiagnosticId = "SYSLIB0051")] #endif public override void GetObjectData(SerializationInfo info, StreamingContext context) diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/PkcsHelpers.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/PkcsHelpers.cs index c8f229368942ef..d2184523ec40f0 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/PkcsHelpers.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/PkcsHelpers.cs @@ -52,7 +52,7 @@ internal static HashAlgorithmName GetDigestAlgorithm(string? oidValue, bool forV case Oids.Sha512: case Oids.RsaPkcs1Sha512 when forVerification: return HashAlgorithmName.SHA512; -#if NET8_0_OR_GREATER +#if NET case Oids.Sha3_256: case Oids.RsaPkcs1Sha3_256 when forVerification: return HashAlgorithmName.SHA3_256; diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSignature.ECDsa.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSignature.ECDsa.cs index 4f3a76b44b2293..9934804a89bce5 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSignature.ECDsa.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSignature.ECDsa.cs @@ -17,7 +17,7 @@ static partial void PrepareRegistrationECDsa(Dictionary lo lookup.Add(Oids.ECDsaWithSha256, new ECDsaCmsSignature(Oids.ECDsaWithSha256, HashAlgorithmName.SHA256)); lookup.Add(Oids.ECDsaWithSha384, new ECDsaCmsSignature(Oids.ECDsaWithSha384, HashAlgorithmName.SHA384)); lookup.Add(Oids.ECDsaWithSha512, new ECDsaCmsSignature(Oids.ECDsaWithSha512, HashAlgorithmName.SHA512)); -#if NET8_0_OR_GREATER +#if NET lookup.Add(Oids.ECDsaWithSha3_256, new ECDsaCmsSignature(Oids.ECDsaWithSha3_256, HashAlgorithmName.SHA3_256)); lookup.Add(Oids.ECDsaWithSha3_384, new ECDsaCmsSignature(Oids.ECDsaWithSha3_384, HashAlgorithmName.SHA3_384)); lookup.Add(Oids.ECDsaWithSha3_512, new ECDsaCmsSignature(Oids.ECDsaWithSha3_512, HashAlgorithmName.SHA3_512)); @@ -137,7 +137,7 @@ protected override bool Sign( Oids.Sha256 => Oids.ECDsaWithSha256, Oids.Sha384 => Oids.ECDsaWithSha384, Oids.Sha512 => Oids.ECDsaWithSha512, -#if NET8_0_OR_GREATER +#if NET Oids.Sha3_256 => Oids.ECDsaWithSha3_256, Oids.Sha3_384 => Oids.ECDsaWithSha3_384, Oids.Sha3_512 => Oids.ECDsaWithSha3_512, diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSignature.RSA.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSignature.RSA.cs index 44c20006bfd6f7..557f7c94e4e4f8 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSignature.RSA.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSignature.RSA.cs @@ -20,7 +20,7 @@ static partial void PrepareRegistrationRsa(Dictionary look lookup.Add(Oids.RsaPkcs1Sha256, new RSAPkcs1CmsSignature(Oids.RsaPkcs1Sha256, HashAlgorithmName.SHA256)); lookup.Add(Oids.RsaPkcs1Sha384, new RSAPkcs1CmsSignature(Oids.RsaPkcs1Sha384, HashAlgorithmName.SHA384)); lookup.Add(Oids.RsaPkcs1Sha512, new RSAPkcs1CmsSignature(Oids.RsaPkcs1Sha512, HashAlgorithmName.SHA512)); -#if NET8_0_OR_GREATER +#if NET lookup.Add(Oids.RsaPkcs1Sha3_256, new RSAPkcs1CmsSignature(Oids.RsaPkcs1Sha3_256, HashAlgorithmName.SHA3_256)); lookup.Add(Oids.RsaPkcs1Sha3_384, new RSAPkcs1CmsSignature(Oids.RsaPkcs1Sha3_384, HashAlgorithmName.SHA3_384)); lookup.Add(Oids.RsaPkcs1Sha3_512, new RSAPkcs1CmsSignature(Oids.RsaPkcs1Sha3_512, HashAlgorithmName.SHA3_512)); diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CryptoSignedXmlRecursionException.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CryptoSignedXmlRecursionException.cs index 773341fe2f5c75..459816dd26be76 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CryptoSignedXmlRecursionException.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CryptoSignedXmlRecursionException.cs @@ -20,7 +20,7 @@ public class CryptoSignedXmlRecursionException : XmlException public CryptoSignedXmlRecursionException() : base() { } public CryptoSignedXmlRecursionException(string message) : base(message) { } public CryptoSignedXmlRecursionException(string message, Exception inner) : base(message, inner) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Security.Permissions/ref/System.Security.Permissions.cs b/src/libraries/System.Security.Permissions/ref/System.Security.Permissions.cs index 5d2fc5fabc8b31..f6cf6ec74ef5d9 100644 --- a/src/libraries/System.Security.Permissions/ref/System.Security.Permissions.cs +++ b/src/libraries/System.Security.Permissions/ref/System.Security.Permissions.cs @@ -676,7 +676,7 @@ public static void RevertPermitOnly() { } public partial class HostProtectionException : System.SystemException { public HostProtectionException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -2061,7 +2061,7 @@ public Hash(System.Reflection.Assembly assembly) { } public static System.Security.Policy.Hash CreateSHA1(byte[] sha1) { throw null; } public static System.Security.Policy.Hash CreateSHA256(byte[] sha256) { throw null; } public byte[] GenerateHash(System.Security.Cryptography.HashAlgorithm hashAlg) { throw null; } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -2131,7 +2131,7 @@ public PermissionRequestEvidence(System.Security.PermissionSet request, System.S public partial class PolicyException : System.SystemException { public PolicyException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Security.Permissions/src/System/Security/HostProtectionException.cs b/src/libraries/System.Security.Permissions/src/System/Security/HostProtectionException.cs index 455e045198c419..c8f860ac5bc169 100644 --- a/src/libraries/System.Security.Permissions/src/System/Security/HostProtectionException.cs +++ b/src/libraries/System.Security.Permissions/src/System/Security/HostProtectionException.cs @@ -48,7 +48,7 @@ public HostProtectionException(string message, HostProtectionResource protectedR DemandedResources = demandedResources; } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -85,7 +85,7 @@ public override string ToString() return sb.ToString(); } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Security.Permissions/src/System/Security/Policy/Hash.cs b/src/libraries/System.Security.Permissions/src/System/Security/Policy/Hash.cs index 85c7aa64d90dd1..2c5b1f79f6166b 100644 --- a/src/libraries/System.Security.Permissions/src/System/Security/Policy/Hash.cs +++ b/src/libraries/System.Security.Permissions/src/System/Security/Policy/Hash.cs @@ -17,7 +17,7 @@ public Hash(System.Reflection.Assembly assembly) { } public static Hash CreateSHA1(byte[] sha1) { return default(Hash); } public static Hash CreateSHA256(byte[] sha256) { return default(Hash); } public byte[] GenerateHash(HashAlgorithm hashAlg) { return null; } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Security.Permissions/src/System/Security/Policy/PolicyException.cs b/src/libraries/System.Security.Permissions/src/System/Security/Policy/PolicyException.cs index 0c80cbc66509b9..5da2875ea6b152 100644 --- a/src/libraries/System.Security.Permissions/src/System/Security/Policy/PolicyException.cs +++ b/src/libraries/System.Security.Permissions/src/System/Security/Policy/PolicyException.cs @@ -11,7 +11,7 @@ namespace System.Security.Policy public partial class PolicyException : System.SystemException { public PolicyException() { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Security.Permissions/src/System/Security/XmlSyntaxException.cs b/src/libraries/System.Security.Permissions/src/System/Security/XmlSyntaxException.cs index b942716638c78f..b90268f100c0a8 100644 --- a/src/libraries/System.Security.Permissions/src/System/Security/XmlSyntaxException.cs +++ b/src/libraries/System.Security.Permissions/src/System/Security/XmlSyntaxException.cs @@ -14,7 +14,7 @@ public XmlSyntaxException(int lineNumber) { } public XmlSyntaxException(int lineNumber, string message) { } public XmlSyntaxException(string message) { } public XmlSyntaxException(string message, Exception inner) { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] #endif private XmlSyntaxException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs index 2a152cb395ca28..966fd0feaf097b 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs @@ -573,11 +573,11 @@ private static TextSyndicationContent ReadTextContentFromHelper(XmlReader reader private static string AsString(DateTimeOffset dateTime) { -#if NET8_0_OR_GREATER +#if NET if (dateTime.TotalOffsetMinutes == 0) #else if (dateTime.Offset == TimeSpan.Zero) -#endif // NET8_0_OR_GREATER +#endif // NET { return dateTime.ToUniversalTime().ToString(Rfc3339UTCDateTimeFormat, CultureInfo.InvariantCulture); } diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs index 3515a3fca5276c..f8788e4b4cff7b 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs @@ -174,11 +174,11 @@ protected virtual void WriteItems(XmlWriter writer, IEnumerable private static string AsString(DateTimeOffset dateTime) { -#if NET8_0_OR_GREATER +#if NET if (dateTime.TotalOffsetMinutes == 0) #else if (dateTime.Offset == TimeSpan.Zero) -#endif // NET8_0_OR_GREATER +#endif // NET { return dateTime.ToUniversalTime().ToString(Rfc822OutputUtcDateTimeFormat, CultureInfo.InvariantCulture); } diff --git a/src/libraries/System.ServiceProcess.ServiceController/ref/System.ServiceProcess.ServiceController.cs b/src/libraries/System.ServiceProcess.ServiceController/ref/System.ServiceProcess.ServiceController.cs index a4223cd161fc17..431c536b91f235 100644 --- a/src/libraries/System.ServiceProcess.ServiceController/ref/System.ServiceProcess.ServiceController.cs +++ b/src/libraries/System.ServiceProcess.ServiceController/ref/System.ServiceProcess.ServiceController.cs @@ -152,7 +152,7 @@ public enum SessionChangeReason public partial class TimeoutException : System.SystemException { public TimeoutException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/TimeoutException.cs b/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/TimeoutException.cs index fa3c5092354158..1abd0d33c85881 100644 --- a/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/TimeoutException.cs +++ b/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/TimeoutException.cs @@ -28,7 +28,7 @@ public TimeoutException(string? message, Exception? innerException) HResult = ServiceControllerTimeout; } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Speech/src/Internal/Synthesis/AudioException.cs b/src/libraries/System.Speech/src/Internal/Synthesis/AudioException.cs index 207e5d0557dd4d..b3b0880c4c24f3 100644 --- a/src/libraries/System.Speech/src/Internal/Synthesis/AudioException.cs +++ b/src/libraries/System.Speech/src/Internal/Synthesis/AudioException.cs @@ -17,7 +17,7 @@ internal AudioException(Interop.WinMM.MMSYSERR errorCode) : base(string.Format(S { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Text.Json/ref/System.Text.Json.cs b/src/libraries/System.Text.Json/ref/System.Text.Json.cs index 5ba98ae680c9eb..cea226f6fadf40 100644 --- a/src/libraries/System.Text.Json/ref/System.Text.Json.cs +++ b/src/libraries/System.Text.Json/ref/System.Text.Json.cs @@ -156,7 +156,7 @@ public void Reset() { } public partial class JsonException : System.Exception { public JsonException() { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif @@ -169,7 +169,7 @@ public JsonException(string? message, string? path, long? lineNumber, long? byte public long? LineNumber { get { throw null; } } public override string Message { get { throw null; } } public string? Path { get { throw null; } } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/JsonException.cs b/src/libraries/System.Text.Json/src/System/Text/Json/JsonException.cs index d3301362fcc1a8..8d8f2b349f5097 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/JsonException.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/JsonException.cs @@ -85,7 +85,7 @@ public JsonException() : base() { } /// /// Thrown when is . /// -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif @@ -107,7 +107,7 @@ protected JsonException(SerializationInfo info, StreamingContext context) : base /// /// The that holds the serialized object data about the exception being thrown. /// The that contains contextual information about the source or destination. -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/JsonHelpers.cs b/src/libraries/System.Text.Json/src/System/Text/Json/JsonHelpers.cs index 46c5b240b8c0db..7b836147cc58cc 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/JsonHelpers.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/JsonHelpers.cs @@ -299,7 +299,7 @@ public static void ValidateInt32MaxArrayLength(uint length) } } -#if !NET8_0_OR_GREATER +#if !NET public static bool HasAllSet(this BitArray bitArray) { for (int i = 0; i < bitArray.Count; i++) diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonArray.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonArray.cs index 54dfdd3c0c9934..4721b3d02aafbc 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonArray.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonArray.cs @@ -162,7 +162,7 @@ private void InitializeFromSpan(ReadOnlySpan items) { List list = new(items.Length); -#if NET8_0_OR_GREATER +#if NET list.AddRange(items); #else foreach (JsonNode? item in items) diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderException.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderException.cs index a50c91c9452913..4a22e0410dacc3 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderException.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderException.cs @@ -13,7 +13,7 @@ public JsonReaderException(string message, long lineNumber, long bytePositionInL { } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] #endif private JsonReaderException(SerializationInfo info, StreamingContext context) : base(info, context) diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.Unescaping.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.Unescaping.cs index 60768cab4d44dc..bc684782277bdf 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.Unescaping.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.Unescaping.cs @@ -321,7 +321,7 @@ public static int TranscodeHelper(ReadOnlySpan utf8Unescaped, Span d public static void ValidateUtf8(ReadOnlySpan utf8Buffer) { -#if NET8_0_OR_GREATER +#if NET if (!Utf8.IsValid(utf8Buffer)) { throw ThrowHelper.GetInvalidOperationException_ReadInvalidUTF8(); diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.cs index bc27b3b0203f89..036429f9922a0d 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderHelper.cs @@ -12,7 +12,7 @@ namespace System.Text.Json internal static partial class JsonReaderHelper { private const string SpecialCharacters = ". '/\"[]()\t\n\r\f\b\\\u0085\u2028\u2029"; -#if NET8_0_OR_GREATER +#if NET private static readonly SearchValues s_specialCharacters = SearchValues.Create(SpecialCharacters); public static bool ContainsSpecialCharacters(this ReadOnlySpan text) => @@ -31,7 +31,7 @@ public static (int, int) CountNewLines(ReadOnlySpan data) { newLines = 1; data = data.Slice(0, lastLineFeedIndex); -#if NET8_0_OR_GREATER +#if NET newLines += data.Count(JsonConstants.LineFeed); #else int pos; diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/VersionConverter.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/VersionConverter.cs index 5f3757bb8ae926..4a8af165f731d2 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/VersionConverter.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/VersionConverter.cs @@ -87,7 +87,7 @@ public override void Write(Utf8JsonWriter writer, Version? value, JsonSerializer } #if NET -#if NET8_0_OR_GREATER +#if NET Span span = stackalloc byte[MaximumVersionLength]; #else Span span = stackalloc char[MaximumVersionLength]; @@ -110,7 +110,7 @@ internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, Version va ArgumentNullException.ThrowIfNull(value); #if NET -#if NET8_0_OR_GREATER +#if NET Span span = stackalloc byte[MaximumVersionLength]; #else Span span = stackalloc char[MaximumVersionLength]; diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.WriteHelpers.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.WriteHelpers.cs index 20c5915e70e99d..6dcbdb5746fa4e 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.WriteHelpers.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.WriteHelpers.cs @@ -200,7 +200,7 @@ rootValue is not null && if (state.PendingTask is not null) { // Exceptions should only be propagated by the resuming converter -#if NET8_0_OR_GREATER +#if NET await state.PendingTask.ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing); #else try diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.cs index 1ab10d31f53b21..6f824283412159 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Writer/JsonWriterHelper.cs @@ -254,13 +254,13 @@ internal static void ValidateNumber(ReadOnlySpan utf8FormattedNumber) } } -#if !NET8_0_OR_GREATER +#if !NET private static readonly UTF8Encoding s_utf8Encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true); #endif public static bool IsValidUtf8String(ReadOnlySpan bytes) { -#if NET8_0_OR_GREATER +#if NET return Utf8.IsValid(bytes); #else try diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs index fad385a183aaca..e9523dbd986a4a 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParseException.cs @@ -32,7 +32,7 @@ internal RegexParseException(RegexParseError error, int offset, string message) Offset = offset; } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Threading.Channels/ref/System.Threading.Channels.netstandard21.cs b/src/libraries/System.Threading.Channels/ref/System.Threading.Channels.netstandard21.cs index c591bf9888138f..f454c70a23fe32 100644 --- a/src/libraries/System.Threading.Channels/ref/System.Threading.Channels.netstandard21.cs +++ b/src/libraries/System.Threading.Channels/ref/System.Threading.Channels.netstandard21.cs @@ -8,7 +8,7 @@ namespace System.Threading.Channels { public partial class ChannelClosedException : System.InvalidOperationException { -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelClosedException.netcoreapp.cs b/src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelClosedException.netcoreapp.cs index 03c846a15a7706..72ef50727c30e8 100644 --- a/src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelClosedException.netcoreapp.cs +++ b/src/libraries/System.Threading.Channels/src/System/Threading/Channels/ChannelClosedException.netcoreapp.cs @@ -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.ComponentModel; #endif using System.Runtime.Serialization; @@ -15,7 +15,7 @@ public partial class ChannelClosedException : InvalidOperationException /// Initializes a new instance of the class with serialized data. /// The object that holds the serialized object data. /// The contextual information about the source or destination. -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/DefaultPartitionedRateLimiter.cs b/src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/DefaultPartitionedRateLimiter.cs index 5c58a1de5970dd..9cb08a5defa7f4 100644 --- a/src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/DefaultPartitionedRateLimiter.cs +++ b/src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/DefaultPartitionedRateLimiter.cs @@ -57,7 +57,7 @@ private async Task RunTimer() try { await Heartbeat().ConfigureAwait( -#if NET8_0_OR_GREATER +#if NET ConfigureAwaitOptions.SuppressThrowing #else false diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/DataflowEtwProvider.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/DataflowEtwProvider.cs index 7c01b09ed6dcf4..2f17ecf0cc8441 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/DataflowEtwProvider.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/DataflowEtwProvider.cs @@ -102,7 +102,7 @@ internal void TaskLaunchedForMessageHandling( } [Event(TASKLAUNCHED_EVENTID, Level = EventLevel.Informational)] -#if !NET8_0_OR_GREATER +#if !NET [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "This calls WriteEvent with all primitive arguments which is safe. Primitives are always serialized properly.")] #endif @@ -161,7 +161,7 @@ internal enum BlockCompletionReason } [Event(BLOCKCOMPLETED_EVENTID, Level = EventLevel.Informational)] -#if !NET8_0_OR_GREATER +#if !NET [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "This calls WriteEvent with all primitive arguments which is safe. Primitives are always serialized properly.")] #endif diff --git a/src/libraries/System.Windows.Extensions/ref/System.Windows.Extensions.cs b/src/libraries/System.Windows.Extensions/ref/System.Windows.Extensions.cs index b3c5b73533c532..7f19175122174a 100644 --- a/src/libraries/System.Windows.Extensions/ref/System.Windows.Extensions.cs +++ b/src/libraries/System.Windows.Extensions/ref/System.Windows.Extensions.cs @@ -11,7 +11,7 @@ public partial class SoundPlayer : System.ComponentModel.Component, System.Runti { public SoundPlayer() { } public SoundPlayer(System.IO.Stream? stream) { } -#if NET8_0_OR_GREATER +#if NET [System.ObsoleteAttribute("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] #endif diff --git a/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs b/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs index 3b3f21c1a1b5e1..cf0189a9b47c30 100644 --- a/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs +++ b/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs @@ -61,7 +61,7 @@ public SoundPlayer(Stream? stream) : this() _stream = stream; } -#if NET8_0_OR_GREATER +#if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] #endif diff --git a/src/tasks/Common/JoinedString.cs b/src/tasks/Common/JoinedString.cs index 947d4e0436066f..3eba1e814beb1e 100644 --- a/src/tasks/Common/JoinedString.cs +++ b/src/tasks/Common/JoinedString.cs @@ -118,7 +118,7 @@ public JoinedStringStreamWriter(string path, bool append) : base(path, append) NewLine = CompileTimeNewLine; } -#if NET8_0_OR_GREATER +#if NET #pragma warning disable CA1822 // Mark members as static #pragma warning disable IDE0060 // Remove unused parameter public void Write([InterpolatedStringHandlerArgument("")] StringSegmentStreamWriterHandler builder) @@ -147,7 +147,7 @@ public void WriteLine(IStringSegments list) } } -#if NET8_0_OR_GREATER +#if NET [InterpolatedStringHandler] internal ref struct StringSegmentStreamWriterHandler {