From dce05cf67d0813e01cb26364263de4fc17bb078c Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Mon, 29 Apr 2024 21:28:04 +0200 Subject: [PATCH] Replace usage of out-of-support TFM compiler directives (#101672) * Replace usage of out-of-support TFM compiler directives ... and directives for TFMs that we don't target anymore in main. Replaces the following directives with `NET` or `!NET`: - `#if NETCOREAPP2*` - `#if !NETCOREAPP2*` - `#if NETCOREAPP3*` - `#if !NETCOREAPP3*` - `#if NET5*` - `#if !NET5*` - `#if NET6*` - `#if !NET6*` - `#if NET7*` - `#if !NET7*` * Update EmitterTests.cs --- .../Utilities/LockFreeReaderHashtable.cs | 4 ++-- .../Common/src/Interop/Interop.Ldap.cs | 14 ++++++------ .../Common/src/Interop/Interop.Odbc.cs | 10 ++++----- .../CryptUI/Interop.CryptUIDlgCertificate.cs | 10 ++++----- .../Interop/Windows/Gdi32/Interop.AbortDoc.cs | 4 ++-- .../Gdi32/Interop.CreateCompatibleBitmap.cs | 4 ++-- .../Windows/Gdi32/Interop.CreateDIBSection.cs | 4 ++-- .../Interop/Windows/Gdi32/Interop.DEVMODE.cs | 2 +- .../Interop/Windows/Gdi32/Interop.EndDoc.cs | 4 ++-- .../Interop/Windows/Gdi32/Interop.EndPage.cs | 4 ++-- .../Windows/Gdi32/Interop.ExtEscape.cs | 6 ++--- .../Windows/Gdi32/Interop.GetDIBits.cs | 6 ++--- .../Windows/Gdi32/Interop.GetObject.cs | 8 +++---- .../Gdi32/Interop.GetPaletteEntries.cs | 4 ++-- .../Gdi32/Interop.IntersectClipRect.cs | 4 ++-- .../Interop/Windows/Gdi32/Interop.ResetDC.cs | 6 ++--- .../Interop/Windows/Gdi32/Interop.StartDoc.cs | 8 +++---- .../Windows/Gdi32/Interop.StartPage.cs | 4 ++-- .../Windows/Kernel32/Interop.SelectObject.cs | 6 ++--- .../Shell32/Interop.ExtractAssociatedIcon.cs | 4 ++-- .../Windows/User32/Interop.CopyImage.cs | 4 ++-- .../Interop.CreateIconFromResourceEx.cs | 2 +- .../Windows/User32/Interop.DestroyIcon.cs | 4 ++-- .../Windows/User32/Interop.DrawIconEx.cs | 8 +++---- .../Windows/User32/Interop.GetIconInfo.cs | 4 ++-- .../User32/Interop.GetSystemMetrics.cs | 2 +- .../Windows/User32/Interop.LoadIcon.cs | 4 ++-- .../Windows/WinHttp/Interop.winhttp.cs | 6 ++--- .../Windows/WinHttp/Interop.winhttp_types.cs | 6 ++--- .../WinMm/Interop.waveOutGetDevCaps.cs | 6 ++--- .../Winspool/Interop.DocumentProperties.cs | 12 +++++----- .../Windows/Winspool/Interop.EnumPrinters.cs | 2 +- .../src/System/CodeDom/CodeTypeReference.cs | 4 ++-- .../CodeDom/CodeTypeReferenceCollection.cs | 4 ++-- .../Data/Common/DbConnectionOptions.Common.cs | 4 ++-- .../src/System/IO/TempFileCollection.cs | 2 +- .../Common/src/System/IO/Win32Marshal.cs | 2 +- .../Cryptography/Asn1/AttributeAsn.manual.cs | 2 +- .../Asn1/X509ExtensionAsn.manual.cs | 2 +- .../Cryptography/CryptoThrowHelper.Windows.cs | 6 ++--- ...0108HmacCounterKdfImplementationManaged.cs | 3 --- .../Threading/Tasks/TaskToAsyncResult.cs | 6 ++--- .../Common/src/System/ThrowHelper.cs | 12 +++++----- .../TestUtilities/System/AssertExtensions.cs | 10 ++++----- .../System/WindowsIdentityFixture.cs | 6 ++--- .../tests/TestUtilities/TestEventListener.cs | 2 +- .../src/IMemoryCache.cs | 2 +- .../MemoryCacheGetCurrentStatisticsTests.cs | 2 +- .../src/PhysicalFilesWatcher.cs | 2 +- .../src/WindowsServiceHelpers.cs | 2 +- .../src/HostBuilder.cs | 5 ----- .../ref/Microsoft.Extensions.Http.cs | 6 ++--- .../DefaultSocketsHttpHandlerBuilder.cs | 2 +- .../HttpClientBuilderExtensions.cs | 2 +- .../ISocketsHttpHandlerBuilder.cs | 2 +- .../SocketsHttpHandlerBuilderExtensions.cs | 2 +- .../src/Logging/HttpClientLoggerHandler.cs | 2 +- .../src/Logging/LoggingHttpMessageHandler.cs | 4 ++-- .../Logging/LoggingScopeHttpMessageHandler.cs | 4 ++-- .../Logging/HttpClientLoggerTest.cs | 6 ++--- .../Logging/LoggingUriOutputTests.cs | 2 +- .../SocketsHttpHandlerConfigurationTest.cs | 2 +- .../TestMessageHandler.cs | 2 +- .../SourceGenerationTests/EmitterTests.cs | 6 ++--- .../Generated/OptionsValidationTests.cs | 2 +- .../SourceGenerationTests/Generated/Utils.cs | 4 ++-- .../TestClasses/Models.cs | 2 +- .../System/Collections/Frozen/Constants.cs | 8 +------ .../Collections/Frozen/FrozenHashTable.cs | 2 +- .../System/Collections/Frozen/FrozenSet.cs | 2 +- .../Collections/Frozen/String/KeyAnalyzer.cs | 2 +- .../Frozen/String/LengthBuckets.cs | 4 ++-- .../Immutable/ImmutableArray_1.Builder.cs | 6 ++--- .../src/System/Polyfills.cs | 8 +++---- .../tests/Frozen/FrozenSetTests.cs | 2 +- .../ImplicitMachineConfigHost.cs | 2 +- .../src/DbConnectionOptions.cs | 4 ++-- .../src/System/Diagnostics/Activity.cs | 4 ++-- .../Diagnostics/Metrics/CounterAggregator.cs | 2 +- .../Diagnostics/Reader/UnsafeNativeMethods.cs | 10 ++++----- .../System/Formats/Asn1/AsnDecoder.Integer.cs | 2 +- .../System/Formats/Asn1/AsnWriter.Integer.cs | 2 +- .../System/Formats/Asn1/SetOfValueComparer.cs | 2 +- .../src/System/IO/Hashing/Crc32.cs | 4 ++-- .../src/System/IO/Hashing/Crc64.cs | 2 +- .../src/System/IO/Hashing/XxHash128.cs | 8 +++---- .../src/System/IO/Hashing/XxHash3.cs | 4 ++-- .../src/System/IO/Hashing/XxHashShared.cs | 22 +++++++++---------- .../tests/NonCryptoHashTestDriver.cs | 2 +- .../System.IO.Hashing/tests/XxHash128Tests.cs | 6 ++--- .../InternalRelationshipCollection.cs | 2 +- .../Packaging/PackUriHelper.PackUriScheme.cs | 2 +- .../tests/PipeReaderCopyToAsyncTests.cs | 2 +- .../src/System/IO/Ports/SerialPort.cs | 2 +- .../Internal/Utilities/StreamExtensions.cs | 2 +- .../Reflection/TypeLoading/General/Helpers.cs | 2 +- .../Reflection/TypeLoading/Types/RoType.cs | 2 +- .../tests/src/Tests/Type/TypeTests.cs | 2 +- .../src/Internal/Cryptography/PkcsHelpers.cs | 2 +- .../System/Security/Cryptography/Xml/Utils.cs | 2 +- .../Cryptography/Xml/XmlResolverHelper.cs | 4 ++-- .../src/System/ServiceModel/XmlBuffer.cs | 2 +- .../src/Internal/Synthesis/AudioBase.cs | 2 +- .../src/Internal/Synthesis/EngineSite.cs | 2 +- .../System/Text/CodePagesEncodingProvider.cs | 2 +- .../System.Text.Json/Common/JsonHelpers.cs | 2 +- .../ref/System.Text.Json.netcoreapp.cs | 2 +- .../Json/Document/JsonDocument.MetadataDb.cs | 2 +- .../src/System/Text/Json/JsonConstants.cs | 2 +- .../Reader/Utf8JsonReader.MultiSegment.cs | 2 +- .../DefaultJsonTypeInfoResolver.Converters.cs | 2 +- .../JsonMetadataServices.Converters.cs | 2 +- .../Metadata/JsonPropertyInfo.cs | 2 +- ...CollectionTests.Dictionary.NonStringKey.cs | 2 +- .../tests/Common/TestClasses/TestClasses.cs | 2 +- .../Text/RegularExpressions/RegexCharClass.cs | 6 ++--- .../Text/RegularExpressions/RegexWriter.cs | 2 +- .../src/System/Threading/StackHelper.cs | 2 +- .../FunctionalTests/Regex.Match.Tests.cs | 14 ++++++------ .../FunctionalTests/Regex.Tests.Common.cs | 4 ++-- .../tests/FunctionalTests/RegexRunnerTests.cs | 2 +- .../src/Base/DataflowBlock.cs | 2 +- .../src/Internal/Common.cs | 2 +- .../src/System/Media/SoundPlayer.cs | 2 +- .../X509Certificates/X509Certificate2UI.cs | 4 ++-- .../WebcilConverter.cs | 4 ++-- .../WebcilWasmWrapper.cs | 8 +++---- .../DiagnosticsServerRouterFactory.cs | 2 +- 128 files changed, 253 insertions(+), 267 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs index 613ec30fa01d2e..1b772684dc1c13 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs @@ -367,7 +367,7 @@ public TValue AddOrGetExisting(TValue value) private TValue AddOrGetExistingInner(TValue value, out bool addedValue) { -#if NET5_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(value); #else if (value == null) @@ -596,7 +596,7 @@ public bool Contains(TKey key) /// Value from the hashtable if found, otherwise null. public TValue GetValueIfExists(TValue value) { -#if NET5_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(value); #else if (value == null) diff --git a/src/libraries/Common/src/Interop/Interop.Ldap.cs b/src/libraries/Common/src/Interop/Interop.Ldap.cs index 7fb63a1d3c5e20..4020dd0fe89bbb 100644 --- a/src/libraries/Common/src/Interop/Interop.Ldap.cs +++ b/src/libraries/Common/src/Interop/Interop.Ldap.cs @@ -4,7 +4,7 @@ using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif using System.Security.Authentication; @@ -31,7 +31,7 @@ internal readonly struct Luid public int HighPart => _highPart; } -#if NET7_0_OR_GREATER +#if NET [NativeMarshalling(typeof(Marshaller))] #endif [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] @@ -49,7 +49,7 @@ internal struct SEC_WINNT_AUTH_IDENTITY_EX public string packageList; public int packageListLength; -#if NET7_0_OR_GREATER +#if NET [CustomMarshaller(typeof(SEC_WINNT_AUTH_IDENTITY_EX), MarshalMode.ManagedToUnmanagedIn, typeof(Marshaller))] internal static class Marshaller { @@ -176,7 +176,7 @@ internal struct LDAP_TIMEVAL public int tv_usec; } -#if NET7_0_OR_GREATER +#if NET [NativeMarshalling(typeof(PinningMarshaller))] #endif [StructLayout(LayoutKind.Sequential)] @@ -185,7 +185,7 @@ internal sealed class BerVal public int bv_len; public IntPtr bv_val = IntPtr.Zero; -#if NET7_0_OR_GREATER +#if NET [CustomMarshaller(typeof(BerVal), MarshalMode.ManagedToUnmanagedIn, typeof(PinningMarshaller))] internal static unsafe class PinningMarshaller { @@ -207,7 +207,7 @@ internal sealed class LdapControl public LdapControl() { } } -#if NET7_0_OR_GREATER +#if NET [NativeMarshalling(typeof(Marshaller))] #endif [StructLayout(LayoutKind.Sequential)] @@ -217,7 +217,7 @@ internal struct LdapReferralCallback public QUERYFORCONNECTIONInternal query; public NOTIFYOFNEWCONNECTIONInternal notify; public DEREFERENCECONNECTIONInternal dereference; -#if NET7_0_OR_GREATER +#if NET public static readonly unsafe int Size = sizeof(Marshaller.MarshalValue.Native); [CustomMarshaller(typeof(LdapReferralCallback), MarshalMode.ManagedToUnmanagedIn, typeof(MarshalValue))] diff --git a/src/libraries/Common/src/Interop/Interop.Odbc.cs b/src/libraries/Common/src/Interop/Interop.Odbc.cs index 250ef4371298b3..3e751856262025 100644 --- a/src/libraries/Common/src/Interop/Interop.Odbc.cs +++ b/src/libraries/Common/src/Interop/Interop.Odbc.cs @@ -5,7 +5,7 @@ using System.Data.Odbc; using System.Runtime.ConstrainedExecution; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif using System.Runtime.Versioning; @@ -38,7 +38,7 @@ internal static partial ODBC32.SQLRETURN SQLAllocHandle( /*SQLUSMALLINT*/ushort ColumnNumber, /*SQLSMALLINT*/ODBC32.SQL_C TargetType, /*SQLPOINTER*/ -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef TargetValue, @@ -64,13 +64,13 @@ internal static partial ODBC32.SQLRETURN SQLBindCol( /*SQLULEN*/IntPtr cbColDef, /*SQLSMALLINT*/IntPtr ibScale, /*SQLPOINTER*/ -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef rgbValue, /*SQLLEN*/IntPtr BufferLength, /*SQLLEN* */ -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef StrLen_or_Ind); @@ -326,7 +326,7 @@ internal static partial ODBC32.SQLRETURN SQLSetConnectAttrW( /*SQLSMALLINT*/short ColumnNumber, /*SQLSMALLINT*/ODBC32.SQL_DESC FieldIdentifier, /*SQLPOINTER*/ -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef CharacterAttribute, diff --git a/src/libraries/Common/src/Interop/Windows/CryptUI/Interop.CryptUIDlgCertificate.cs b/src/libraries/Common/src/Interop/Windows/CryptUI/Interop.CryptUIDlgCertificate.cs index e58a0b497dc412..97b5d4bba72617 100644 --- a/src/libraries/Common/src/Interop/Windows/CryptUI/Interop.CryptUIDlgCertificate.cs +++ b/src/libraries/Common/src/Interop/Windows/CryptUI/Interop.CryptUIDlgCertificate.cs @@ -4,7 +4,7 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif using Microsoft.Win32.SafeHandles; @@ -13,7 +13,7 @@ internal static partial class Interop { internal static partial class CryptUI { -#if NET7_0_OR_GREATER +#if NET [NativeMarshalling(typeof(Marshaller))] #else [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] @@ -39,7 +39,7 @@ internal struct CRYPTUI_VIEWCERTIFICATE_STRUCTW internal IntPtr rgPropSheetPages; internal uint nStartPage; -#if NET7_0_OR_GREATER +#if NET [CustomMarshaller(typeof(CRYPTUI_VIEWCERTIFICATE_STRUCTW), MarshalMode.Default, typeof(Marshaller))] public static class Marshaller { @@ -127,7 +127,7 @@ public CRYPTUI_VIEWCERTIFICATE_STRUCTW ToManaged() #endif } -#if NET7_0_OR_GREATER +#if NET [NativeMarshalling(typeof(Marshaller))] #else [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] @@ -151,7 +151,7 @@ internal struct CRYPTUI_SELECTCERTIFICATE_STRUCTW internal IntPtr rgPropSheetPages; internal IntPtr hSelectedCertStore; -#if NET7_0_OR_GREATER +#if NET [CustomMarshaller(typeof(CRYPTUI_SELECTCERTIFICATE_STRUCTW), MarshalMode.Default, typeof(Marshaller))] public static class Marshaller { diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.AbortDoc.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.AbortDoc.cs index cca83bef74b6a4..0326ead026c334 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.AbortDoc.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.AbortDoc.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -12,7 +12,7 @@ internal static partial class Gdi32 { [LibraryImport(Libraries.Gdi32, SetLastError = true)] internal static partial int AbortDoc( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hDC); diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleBitmap.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleBitmap.cs index e051d8f8d70055..fdfc84cddf583c 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleBitmap.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleBitmap.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -13,7 +13,7 @@ internal static partial class Gdi32 { [LibraryImport(Libraries.Gdi32, SetLastError = true)] internal static partial IntPtr CreateCompatibleBitmap( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hDC, int width, int height); diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateDIBSection.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateDIBSection.cs index ca024801b4287e..2654d0e653ad19 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateDIBSection.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateDIBSection.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -13,7 +13,7 @@ internal static partial class Gdi32 { [LibraryImport(Libraries.Gdi32, SetLastError = true)] internal static partial IntPtr CreateDIBSection( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hdc, ref BITMAPINFO_FLAT bmi, int iUsage, ref IntPtr ppvBits, IntPtr hSection, int dwOffset); diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.DEVMODE.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.DEVMODE.cs index aa26afa85665fb..bb0fa59f771279 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.DEVMODE.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.DEVMODE.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndDoc.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndDoc.cs index b65d8106b34392..2bd8ad72416341 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndDoc.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndDoc.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -12,7 +12,7 @@ internal static partial class Gdi32 { [LibraryImport(Libraries.Gdi32, SetLastError = true)] internal static partial int EndDoc( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hDC); diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndPage.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndPage.cs index f09232b01fbacc..0349c5044ba194 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndPage.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndPage.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -12,7 +12,7 @@ internal static partial class Gdi32 { [LibraryImport(Libraries.Gdi32, SetLastError = true)] internal static partial int EndPage( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hDC); diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ExtEscape.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ExtEscape.cs index 449ba1b934b333..6ade151f8b0660 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ExtEscape.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ExtEscape.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -16,14 +16,14 @@ internal static partial class Gdi32 [LibraryImport(Libraries.Gdi32, SetLastError = true)] internal static partial int ExtEscape( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hDC, int nEscape, int cbInput, ref int inData, int cbOutput, out int outData); [LibraryImport(Libraries.Gdi32, SetLastError = true)] internal static partial int ExtEscape( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hDC, int nEscape, int cbInput, byte[] inData, int cbOutput, out int outData); diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetDIBits.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetDIBits.cs index 03cbc74a846d5f..11900ac16602ca 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetDIBits.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetDIBits.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -13,11 +13,11 @@ internal static partial class Gdi32 { [LibraryImport(Libraries.Gdi32)] internal static partial int GetDIBits( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hdc, -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hbm, int arg1, int arg2, IntPtr arg3, ref BITMAPINFO_FLAT bmi, int arg5); diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetObject.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetObject.cs index 83fcfa6f9d2359..afb88d5bd14a54 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetObject.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetObject.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -13,20 +13,20 @@ internal static partial class Gdi32 { [LibraryImport(Libraries.Gdi32, EntryPoint = "GetObjectW", SetLastError = true)] internal static partial int GetObject( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hObject, int nSize, ref BITMAP bm); [LibraryImport(Libraries.Gdi32, EntryPoint = "GetObjectW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] internal static partial int GetObject( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hObject, int nSize, ref Interop.User32.LOGFONT lf); internal static unsafe int GetObject( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hObject, ref Interop.User32.LOGFONT lp) diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetPaletteEntries.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetPaletteEntries.cs index 4f2f2ed8035918..ab2ad0b6ea33bc 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetPaletteEntries.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetPaletteEntries.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -12,7 +12,7 @@ internal static partial class Gdi32 { [LibraryImport(Libraries.Gdi32)] internal static partial uint GetPaletteEntries( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hpal, int iStartIndex, int nEntries, byte[] lppe); diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.IntersectClipRect.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.IntersectClipRect.cs index a82d6c5514ed2f..0084bcd6265270 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.IntersectClipRect.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.IntersectClipRect.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -13,7 +13,7 @@ internal static partial class Gdi32 { [LibraryImport(Libraries.Gdi32, SetLastError = true)] internal static partial int IntersectClipRect( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hDC, int x1, int y1, int x2, int y2); diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ResetDC.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ResetDC.cs index 3737f3f46699b1..e26750aa2895f9 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ResetDC.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ResetDC.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -13,11 +13,11 @@ internal static partial class Gdi32 { [LibraryImport(Libraries.Gdi32, EntryPoint = "ResetDCW", SetLastError = true)] internal static partial IntPtr /*HDC*/ ResetDC( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hDC, -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef /*DEVMODE*/ lpDevMode); diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.StartDoc.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.StartDoc.cs index c62da1844b8e6e..8199ff3f217ff3 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.StartDoc.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.StartDoc.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -13,12 +13,12 @@ internal static partial class Gdi32 { [LibraryImport(Libraries.Gdi32, EntryPoint = "StartDocW", SetLastError = true)] internal static partial int StartDoc( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hDC, in DOCINFO lpDocInfo); -#if NET7_0_OR_GREATER +#if NET [NativeMarshalling(typeof(Marshaller))] #endif [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] @@ -32,7 +32,7 @@ internal struct DOCINFO public DOCINFO() { } -#if NET7_0_OR_GREATER +#if NET [CustomMarshaller(typeof(DOCINFO), MarshalMode.ManagedToUnmanagedIn, typeof(Marshaller))] public static class Marshaller { diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.StartPage.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.StartPage.cs index 00ecc844d7e8a3..549151d43337dd 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.StartPage.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.StartPage.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -12,7 +12,7 @@ internal static partial class Gdi32 { [LibraryImport(Libraries.Gdi32, SetLastError = true)] internal static partial int StartPage( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hDC); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SelectObject.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SelectObject.cs index efcc90a00fb256..da8fb34e900af0 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SelectObject.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SelectObject.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -13,11 +13,11 @@ internal static partial class Kernel32 { [LibraryImport(Libraries.Gdi32, SetLastError = true)] internal static partial IntPtr SelectObject( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hdc, -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef obj); diff --git a/src/libraries/Common/src/Interop/Windows/Shell32/Interop.ExtractAssociatedIcon.cs b/src/libraries/Common/src/Interop/Windows/Shell32/Interop.ExtractAssociatedIcon.cs index 6162795d061e19..d71fc5b7a0835a 100644 --- a/src/libraries/Common/src/Interop/Windows/Shell32/Interop.ExtractAssociatedIcon.cs +++ b/src/libraries/Common/src/Interop/Windows/Shell32/Interop.ExtractAssociatedIcon.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -13,7 +13,7 @@ internal static partial class Shell32 { [LibraryImport(Libraries.Shell32, EntryPoint = "ExtractAssociatedIconW")] internal static unsafe partial IntPtr ExtractAssociatedIcon( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hInst, char* iconPath, ref int index); diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.CopyImage.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.CopyImage.cs index 4211c156c36552..b971b37309311e 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.CopyImage.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.CopyImage.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -13,7 +13,7 @@ internal static partial class User32 { [LibraryImport(Libraries.User32, SetLastError = true)] internal static partial IntPtr CopyImage( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hImage, int uType, int cxDesired, int cyDesired, int fuFlags); diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateIconFromResourceEx.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateIconFromResourceEx.cs index a295619f2ac4a3..9c11ee7eba900b 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateIconFromResourceEx.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateIconFromResourceEx.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.DestroyIcon.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.DestroyIcon.cs index 1528c6ae181eb3..782dbcec0e7f4c 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.DestroyIcon.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.DestroyIcon.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -14,7 +14,7 @@ internal static partial class User32 [LibraryImport(Libraries.User32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static partial bool DestroyIcon( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hIcon); diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.DrawIconEx.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.DrawIconEx.cs index 6ac69016bde602..9c0a0bfee89ea3 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.DrawIconEx.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.DrawIconEx.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -14,15 +14,15 @@ internal static partial class User32 [LibraryImport(Libraries.User32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static partial bool DrawIconEx( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hDC, int x, int y, -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hIcon, int width, int height, int iStepIfAniCursor, -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hBrushFlickerFree, int diFlags); diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetIconInfo.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetIconInfo.cs index e97f54e2e8f6ee..faa505574e6b8c 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetIconInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetIconInfo.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -14,7 +14,7 @@ internal static partial class User32 [LibraryImport(Libraries.User32, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static partial bool GetIconInfo( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hIcon, ref ICONINFO info); diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetSystemMetrics.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetSystemMetrics.cs index 761e69a4a2c829..4232c4348719e9 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetSystemMetrics.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetSystemMetrics.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadIcon.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadIcon.cs index f391366d89b125..378129442bf185 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadIcon.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadIcon.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -13,7 +13,7 @@ internal static partial class User32 { [LibraryImport(Libraries.User32, EntryPoint = "LoadIconW", SetLastError = true)] internal static partial IntPtr LoadIcon( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hInst, IntPtr iconId); diff --git a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs index 7e1010013c35d5..69457b97300730 100644 --- a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs +++ b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif using System.Text; @@ -45,7 +45,7 @@ public static partial SafeWinHttpHandle WinHttpOpenRequest( [return: MarshalAs(UnmanagedType.Bool)] public static partial bool WinHttpAddRequestHeaders( SafeWinHttpHandle requestHandle, -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(SimpleStringBufferMarshaller))] StringBuilder headers, #else #pragma warning disable CA1838 // Uses pooled StringBuilder @@ -55,7 +55,7 @@ public static partial bool WinHttpAddRequestHeaders( uint headersLength, uint modifiers); -#if NET7_0_OR_GREATER +#if NET [CustomMarshaller(typeof(StringBuilder), MarshalMode.ManagedToUnmanagedIn, typeof(SimpleStringBufferMarshaller))] private static unsafe class SimpleStringBufferMarshaller { diff --git a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs index 1cbdfa79d5962a..e76fa9b67e5bcb 100644 --- a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs +++ b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif using System.Text; @@ -247,7 +247,7 @@ public delegate void WINHTTP_STATUS_CALLBACK( IntPtr statusInformation, uint statusInformationLength); -#if NET7_0_OR_GREATER +#if NET [NativeMarshalling(typeof(Marshaller))] #endif [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] @@ -261,7 +261,7 @@ public struct WINHTTP_AUTOPROXY_OPTIONS public uint Reserved2; [MarshalAs(UnmanagedType.Bool)] public bool AutoLoginIfChallenged; -#if NET7_0_OR_GREATER +#if NET [CustomMarshaller(typeof(WINHTTP_AUTOPROXY_OPTIONS), MarshalMode.Default, typeof(Marshaller))] public static class Marshaller { diff --git a/src/libraries/Common/src/Interop/Windows/WinMm/Interop.waveOutGetDevCaps.cs b/src/libraries/Common/src/Interop/Windows/WinMm/Interop.waveOutGetDevCaps.cs index a9ebcba2950c55..954101a9c3cbee 100644 --- a/src/libraries/Common/src/Interop/Windows/WinMm/Interop.waveOutGetDevCaps.cs +++ b/src/libraries/Common/src/Interop/Windows/WinMm/Interop.waveOutGetDevCaps.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -12,7 +12,7 @@ internal static partial class Interop internal static partial class WinMM { #pragma warning disable CA1823 // unused fields -#if NET7_0_OR_GREATER +#if NET [NativeMarshalling(typeof(Marshaller))] #endif internal struct WAVEOUTCAPS @@ -27,7 +27,7 @@ internal struct WAVEOUTCAPS private ushort wChannels; private ushort wReserved1; private ushort dwSupport; -#if NET7_0_OR_GREATER +#if NET [CustomMarshaller(typeof(WAVEOUTCAPS), MarshalMode.Default, typeof(Marshaller))] public static class Marshaller { diff --git a/src/libraries/Common/src/Interop/Windows/Winspool/Interop.DocumentProperties.cs b/src/libraries/Common/src/Interop/Windows/Winspool/Interop.DocumentProperties.cs index bf54cfb1b5b90c..8e7b6ce0c9d763 100644 --- a/src/libraries/Common/src/Interop/Windows/Winspool/Interop.DocumentProperties.cs +++ b/src/libraries/Common/src/Interop/Windows/Winspool/Interop.DocumentProperties.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif @@ -13,26 +13,26 @@ internal static partial class Winspool { [LibraryImport(Libraries.Winspool, EntryPoint = "DocumentPropertiesW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] internal static partial int DocumentProperties( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hwnd, -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hPrinter, string pDeviceName, IntPtr /*DEVMODE*/ pDevModeOutput, -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef /*DEVMODE*/ pDevModeInput, int fMode); [LibraryImport(Libraries.Winspool, EntryPoint = "DocumentPropertiesW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] internal static partial int DocumentProperties( -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hwnd, -#if NET7_0_OR_GREATER +#if NET [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hPrinter, string pDeviceName, IntPtr /*DEVMODE*/ pDevModeOutput, IntPtr /*DEVMODE*/ pDevModeInput, int fMode); diff --git a/src/libraries/Common/src/Interop/Windows/Winspool/Interop.EnumPrinters.cs b/src/libraries/Common/src/Interop/Windows/Winspool/Interop.EnumPrinters.cs index ca967e11d16d86..baeed522bb0c82 100644 --- a/src/libraries/Common/src/Interop/Windows/Winspool/Interop.EnumPrinters.cs +++ b/src/libraries/Common/src/Interop/Windows/Winspool/Interop.EnumPrinters.cs @@ -3,7 +3,7 @@ using System; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif diff --git a/src/libraries/Common/src/System/CodeDom/CodeTypeReference.cs b/src/libraries/Common/src/System/CodeDom/CodeTypeReference.cs index 615d6017e37e37..cb75ff887f6871 100644 --- a/src/libraries/Common/src/System/CodeDom/CodeTypeReference.cs +++ b/src/libraries/Common/src/System/CodeDom/CodeTypeReference.cs @@ -42,7 +42,7 @@ public CodeTypeReference() public CodeTypeReference(Type type) { -#if NET5_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(type); #else if (type is null) @@ -271,7 +271,7 @@ private void Initialize(string? typeName, CodeTypeReferenceOptions options) } // Now see if we have some arity. baseType could be null if this is an array type. -#if NET5_0_OR_GREATER +#if NET if (_baseType != null && _baseType.Contains('`')) // string.Contains(char) is .NetCore2.1+ specific #else if (_baseType != null && _baseType.IndexOf('`') != -1) // string.Contains(char) is .NetCore2.1+ specific diff --git a/src/libraries/Common/src/System/CodeDom/CodeTypeReferenceCollection.cs b/src/libraries/Common/src/System/CodeDom/CodeTypeReferenceCollection.cs index 21b2ae857366ac..55119bc720664b 100644 --- a/src/libraries/Common/src/System/CodeDom/CodeTypeReferenceCollection.cs +++ b/src/libraries/Common/src/System/CodeDom/CodeTypeReferenceCollection.cs @@ -41,7 +41,7 @@ public CodeTypeReference this[int index] public void AddRange(CodeTypeReference[] value) { -#if NET5_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(value); #else if (value is null) @@ -58,7 +58,7 @@ public void AddRange(CodeTypeReference[] value) public void AddRange(CodeTypeReferenceCollection value) { -#if NET5_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(value); #else if (value is null) diff --git a/src/libraries/Common/src/System/Data/Common/DbConnectionOptions.Common.cs b/src/libraries/Common/src/System/Data/Common/DbConnectionOptions.Common.cs index 936c81c094e45d..da3b254f99eb25 100644 --- a/src/libraries/Common/src/System/Data/Common/DbConnectionOptions.Common.cs +++ b/src/libraries/Common/src/System/Data/Common/DbConnectionOptions.Common.cs @@ -50,7 +50,7 @@ internal partial class DbConnectionOptions private static readonly Regex s_connectionStringRegex = CreateConnectionStringRegex(); private static readonly Regex s_connectionStringRegexOdbc = CreateConnectionStringRegexOdbc(); -#if NET7_0_OR_GREATER +#if NET [GeneratedRegex(ConnectionStringPattern, RegexOptions.ExplicitCapture)] private static partial Regex CreateConnectionStringRegex(); @@ -67,7 +67,7 @@ internal partial class DbConnectionOptions private static readonly Regex s_connectionStringQuoteValueRegex = CreateConnectionStringQuoteValueRegex(); // generally do not quote the value if it matches the pattern private static readonly Regex s_connectionStringQuoteOdbcValueRegex = CreateConnectionStringQuoteOdbcValueRegex(); // do not quote odbc value if it matches this pattern -#if NET7_0_OR_GREATER +#if NET [GeneratedRegex("^(?![;\\s])[^\\p{Cc}]+(? public static IAsyncResult Begin(Task task, AsyncCallback? callback, object? state) { -#if NET6_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(task); #else if (task is null) @@ -68,7 +68,7 @@ public static TResult End(IAsyncResult asyncResult) => /// was not produced by a call to . public static Task Unwrap(IAsyncResult asyncResult) { -#if NET6_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(asyncResult); #else if (asyncResult is null) @@ -97,7 +97,7 @@ public static Task Unwrap(IAsyncResult asyncResult) /// public static Task Unwrap(IAsyncResult asyncResult) { -#if NET6_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(asyncResult); #else if (asyncResult is null) diff --git a/src/libraries/Common/src/System/ThrowHelper.cs b/src/libraries/Common/src/System/ThrowHelper.cs index 4257c05891e32c..098b8321492764 100644 --- a/src/libraries/Common/src/System/ThrowHelper.cs +++ b/src/libraries/Common/src/System/ThrowHelper.cs @@ -15,7 +15,7 @@ internal static partial class ThrowHelper /// The reference type argument to validate as non-null. /// The name of the parameter with which corresponds. internal static void ThrowIfNull( -#if NETCOREAPP3_0_OR_GREATER +#if NET [NotNull] #endif object? argument, @@ -27,7 +27,7 @@ internal static void ThrowIfNull( } } -#if NETCOREAPP3_0_OR_GREATER +#if NET [DoesNotReturn] #endif private static void Throw(string? paramName) => throw new ArgumentNullException(paramName); @@ -40,17 +40,17 @@ internal static void ThrowIfNull( /// The name of the parameter being checked. /// The original value of . [MethodImpl(MethodImplOptions.AggressiveInlining)] -#if NETCOREAPP3_0_OR_GREATER +#if NET [return: NotNull] #endif public static string IfNullOrWhitespace( -#if NETCOREAPP3_0_OR_GREATER +#if NET [NotNull] #endif string? argument, [CallerArgumentExpression(nameof(argument))] string paramName = "") { -#if !NETCOREAPP3_1_OR_GREATER +#if !NET if (argument == null) { throw new ArgumentNullException(paramName); @@ -74,7 +74,7 @@ public static string IfNullOrWhitespace( } } -#if !NETCOREAPP3_0_OR_GREATER +#if !NET namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] diff --git a/src/libraries/Common/tests/TestUtilities/System/AssertExtensions.cs b/src/libraries/Common/tests/TestUtilities/System/AssertExtensions.cs index 232c05afb8d271..0d658dae016cc7 100644 --- a/src/libraries/Common/tests/TestUtilities/System/AssertExtensions.cs +++ b/src/libraries/Common/tests/TestUtilities/System/AssertExtensions.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#if NET6_0_OR_GREATER +#if NET using System.Runtime.Intrinsics; #endif using System.Threading; @@ -710,7 +710,7 @@ static unsafe bool IsPositiveZero(double value) return (*(ulong*)(&value)) == 0x0000000000000000; } -#if NET6_0_OR_GREATER +#if NET static unsafe bool IsNegativeZero(Half value) { return (*(ushort*)(&value)) == 0x8000; @@ -780,7 +780,7 @@ static string ToStringPadded(double value) } } -#if NET6_0_OR_GREATER +#if NET static string ToStringPadded(Half value) { if (Half.IsNaN(value)) @@ -1036,7 +1036,7 @@ public static void Equal(float expected, float actual, float variance) } } -#if NET6_0_OR_GREATER +#if NET /// Verifies that two values are equal, within the . /// The expected value /// The value to be compared against @@ -1196,7 +1196,7 @@ static unsafe int SingleToInt32Bits(float value) throw EqualException.ForMismatchedValues(ToStringPadded(expected), ToStringPadded(actual)); } -#if NET6_0_OR_GREATER +#if NET /// Verifies that two values's binary representations are identical. /// The expected value /// The value to be compared against diff --git a/src/libraries/Common/tests/TestUtilities/System/WindowsIdentityFixture.cs b/src/libraries/Common/tests/TestUtilities/System/WindowsIdentityFixture.cs index b4d9be2a52744d..2817d305e6d0a1 100644 --- a/src/libraries/Common/tests/TestUtilities/System/WindowsIdentityFixture.cs +++ b/src/libraries/Common/tests/TestUtilities/System/WindowsIdentityFixture.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Net; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif using System.Security.Cryptography; @@ -127,7 +127,7 @@ private void CreateUser() [LibraryImport("netapi32.dll")] internal static partial uint NetUserDel([MarshalAs(UnmanagedType.LPWStr)] string servername, [MarshalAs(UnmanagedType.LPWStr)] string username); -#if NET7_0_OR_GREATER +#if NET [NativeMarshalling(typeof(USER_INFO_1.Marshaller))] #endif [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] @@ -142,7 +142,7 @@ internal struct USER_INFO_1 public uint usri1_flags; public string usri1_script_path; -#if NET7_0_OR_GREATER +#if NET [CustomMarshaller(typeof(USER_INFO_1), MarshalMode.Default, typeof(Marshaller))] public static class Marshaller { diff --git a/src/libraries/Common/tests/TestUtilities/TestEventListener.cs b/src/libraries/Common/tests/TestUtilities/TestEventListener.cs index 3c33bdb633e36b..8cb70ee3cbd8c9 100644 --- a/src/libraries/Common/tests/TestUtilities/TestEventListener.cs +++ b/src/libraries/Common/tests/TestUtilities/TestEventListener.cs @@ -99,7 +99,7 @@ protected override void OnEventSourceCreated(EventSource eventSource) protected override void OnEventWritten(EventWrittenEventArgs eventData) { StringBuilder sb = new StringBuilder(). -#if NETCOREAPP2_2_OR_GREATER || NETSTANDARD2_1_OR_GREATER +#if NET || NETSTANDARD2_1_OR_GREATER Append($"{eventData.TimeStamp:HH:mm:ss.fffffff}[{eventData.EventName}] "); #else Append($"[{eventData.EventName}] "); diff --git a/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IMemoryCache.cs b/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IMemoryCache.cs index ccce249b23d958..8388a9f0433eb1 100644 --- a/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IMemoryCache.cs +++ b/src/libraries/Microsoft.Extensions.Caching.Abstractions/src/IMemoryCache.cs @@ -31,7 +31,7 @@ public interface IMemoryCache : IDisposable /// An object identifying the entry. void Remove(object key); -#if NET6_0_OR_GREATER +#if NET /// /// Gets a snapshot of the cache statistics if available. /// diff --git a/src/libraries/Microsoft.Extensions.Caching.Memory/tests/MemoryCacheGetCurrentStatisticsTests.cs b/src/libraries/Microsoft.Extensions.Caching.Memory/tests/MemoryCacheGetCurrentStatisticsTests.cs index cee6245f3e9c6b..576b7e103aebae 100644 --- a/src/libraries/Microsoft.Extensions.Caching.Memory/tests/MemoryCacheGetCurrentStatisticsTests.cs +++ b/src/libraries/Microsoft.Extensions.Caching.Memory/tests/MemoryCacheGetCurrentStatisticsTests.cs @@ -106,7 +106,7 @@ public void GetCurrentStatistics_UpdateAfterExistingItemExpired_CurrentEstimated } } -#if NET6_0_OR_GREATER +#if NET [Fact] public void GetCurrentStatistics_DIMReturnsNull() { diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs index db0a767573a1e8..eaa53fec71ede1 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs @@ -160,7 +160,7 @@ private IChangeToken GetOrAddChangeToken(string pattern) } IChangeToken changeToken; -#if NET5_0_OR_GREATER +#if NET bool isWildCard = pattern.Contains('*'); #else bool isWildCard = pattern.IndexOf('*') != -1; diff --git a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceHelpers.cs b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceHelpers.cs index 9de601ddebe7d5..05eed40ff6df48 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceHelpers.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceHelpers.cs @@ -28,7 +28,7 @@ private static bool GetIsWindowsService() if ( #if NETFRAMEWORK Environment.OSVersion.Platform != PlatformID.Win32NT -#elif NET5_0_OR_GREATER +#elif NET !OperatingSystem.IsWindows() #else !RuntimeInformation.IsOSPlatform(OSPlatform.Windows) diff --git a/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.cs b/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.cs index 7a965e0efc85f5..4a9806a2fcd787 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.cs @@ -190,11 +190,6 @@ internal static DiagnosticListener LogHostBuilding(HostApplicationBuilder hostAp return diagnosticListener; } -// Remove when https://github.com/dotnet/runtime/pull/78532 is merged and consumed by the used SDK. -#if NET7_0 - [UnconditionalSuppressMessage("AOT", "IL3050:RequiresDynamicCode", - Justification = "DiagnosticSource is used here to pass objects in-memory to code using HostFactoryResolver. This won't require creating new generic types.")] -#endif [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "The values being passed into Write are being consumed by the application already.")] private static void Write<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>( diff --git a/src/libraries/Microsoft.Extensions.Http/ref/Microsoft.Extensions.Http.cs b/src/libraries/Microsoft.Extensions.Http/ref/Microsoft.Extensions.Http.cs index 51891e8ebcf754..8c791124208828 100644 --- a/src/libraries/Microsoft.Extensions.Http/ref/Microsoft.Extensions.Http.cs +++ b/src/libraries/Microsoft.Extensions.Http/ref/Microsoft.Extensions.Http.cs @@ -28,7 +28,7 @@ public static partial class HttpClientBuilderExtensions public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder RedactLoggedHeaders(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, System.Func shouldRedactHeaderValue) { throw null; } public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder RemoveAllLoggers(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder) { throw null; } public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder SetHandlerLifetime(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, System.TimeSpan handlerLifetime) { throw null; } -#if NET5_0_OR_GREATER +#if NET [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder UseSocketsHttpHandler(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, System.Action? configureHandler = null) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] @@ -64,14 +64,14 @@ public partial interface IHttpClientBuilder string Name { get; } Microsoft.Extensions.DependencyInjection.IServiceCollection Services { get; } } -#if NET5_0_OR_GREATER +#if NET public partial interface ISocketsHttpHandlerBuilder { string Name { get; } Microsoft.Extensions.DependencyInjection.IServiceCollection Services { get; } } #endif -#if NET5_0_OR_GREATER +#if NET public static partial class SocketsHttpHandlerBuilderExtensions { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] diff --git a/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/DefaultSocketsHttpHandlerBuilder.cs b/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/DefaultSocketsHttpHandlerBuilder.cs index 57b905c0f3e6e0..61986cedfbe1a3 100644 --- a/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/DefaultSocketsHttpHandlerBuilder.cs +++ b/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/DefaultSocketsHttpHandlerBuilder.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 NET5_0_OR_GREATER +#if NET namespace Microsoft.Extensions.DependencyInjection { internal sealed class DefaultSocketsHttpHandlerBuilder : ISocketsHttpHandlerBuilder diff --git a/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/HttpClientBuilderExtensions.cs b/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/HttpClientBuilderExtensions.cs index a9adb32fc5d84c..758a989be3a8b2 100644 --- a/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/HttpClientBuilderExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/HttpClientBuilderExtensions.cs @@ -265,7 +265,7 @@ public static IHttpClientBuilder ConfigureHttpMessageHandlerBuilder(this IHttpCl return builder; } -#if NET5_0_OR_GREATER +#if NET /// /// Adds or updates as a primary handler for a named . If provided, /// also adds a delegate that will be used to configure the primary . diff --git a/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/ISocketsHttpHandlerBuilder.cs b/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/ISocketsHttpHandlerBuilder.cs index d7509e009c9c47..75333f8d747c71 100644 --- a/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/ISocketsHttpHandlerBuilder.cs +++ b/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/ISocketsHttpHandlerBuilder.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 NET5_0_OR_GREATER +#if NET namespace Microsoft.Extensions.DependencyInjection { /// diff --git a/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/SocketsHttpHandlerBuilderExtensions.cs b/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/SocketsHttpHandlerBuilderExtensions.cs index 0d56606b742bde..d3bb98c8a11620 100644 --- a/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/SocketsHttpHandlerBuilderExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Http/src/DependencyInjection/SocketsHttpHandlerBuilderExtensions.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 NET5_0_OR_GREATER +#if NET using System; using System.Net; using System.Net.Http; diff --git a/src/libraries/Microsoft.Extensions.Http/src/Logging/HttpClientLoggerHandler.cs b/src/libraries/Microsoft.Extensions.Http/src/Logging/HttpClientLoggerHandler.cs index 087ec81fbb6cd9..a7aeebe8578f3e 100644 --- a/src/libraries/Microsoft.Extensions.Http/src/Logging/HttpClientLoggerHandler.cs +++ b/src/libraries/Microsoft.Extensions.Http/src/Logging/HttpClientLoggerHandler.cs @@ -61,7 +61,7 @@ protected override async Task SendAsync(HttpRequestMessage } } -#if NET5_0_OR_GREATER +#if NET protected override HttpResponseMessage Send(HttpRequestMessage request, CancellationToken cancellationToken) { ThrowHelper.ThrowIfNull(request); diff --git a/src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingHttpMessageHandler.cs b/src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingHttpMessageHandler.cs index 5056474e9ead2f..e592e7d236fbb4 100644 --- a/src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingHttpMessageHandler.cs +++ b/src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingHttpMessageHandler.cs @@ -62,7 +62,7 @@ async Task Core(HttpRequestMessage request, bool useAsync, var stopwatch = ValueStopwatch.StartNew(); HttpResponseMessage response = useAsync ? await base.SendAsync(request, cancellationToken).ConfigureAwait(false) -#if NET5_0_OR_GREATER +#if NET : base.Send(request, cancellationToken); #else : throw new NotImplementedException("Unreachable code"); @@ -78,7 +78,7 @@ async Task Core(HttpRequestMessage request, bool useAsync, protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) => SendCoreAsync(request, useAsync: true, cancellationToken); -#if NET5_0_OR_GREATER +#if NET /// /// Logs the request to and response from the sent . protected override HttpResponseMessage Send(HttpRequestMessage request, CancellationToken cancellationToken) diff --git a/src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingScopeHttpMessageHandler.cs b/src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingScopeHttpMessageHandler.cs index e170acbfe83c80..1894a005f84a68 100644 --- a/src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingScopeHttpMessageHandler.cs +++ b/src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingScopeHttpMessageHandler.cs @@ -63,7 +63,7 @@ async Task Core(HttpRequestMessage request, bool useAsync, Log.RequestPipelineStart(_logger, request, shouldRedactHeaderValue); HttpResponseMessage response = useAsync ? await base.SendAsync(request, cancellationToken).ConfigureAwait(false) -#if NET5_0_OR_GREATER +#if NET : base.Send(request, cancellationToken); #else : throw new NotImplementedException("Unreachable code"); @@ -80,7 +80,7 @@ async Task Core(HttpRequestMessage request, bool useAsync, protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) => SendCoreAsync(request, useAsync: true, cancellationToken); -#if NET5_0_OR_GREATER +#if NET /// /// Logs the request to and response from the sent . protected override HttpResponseMessage Send(HttpRequestMessage request, CancellationToken cancellationToken) diff --git a/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/HttpClientLoggerTest.cs b/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/HttpClientLoggerTest.cs index 6fb8e2dd8f7a98..039ba46b186251 100644 --- a/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/HttpClientLoggerTest.cs +++ b/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/HttpClientLoggerTest.cs @@ -156,7 +156,7 @@ private void AssertCounters(TestCountingLogger testLogger, int requestCount, boo } } -#if NET5_0_OR_GREATER +#if NET [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNetCore))] [InlineData(false, false)] [InlineData(false, true)] @@ -588,7 +588,7 @@ private async Task SendAsyncCore(HttpRequestMessage request } else { -#if NET5_0_OR_GREATER +#if NET return base.Send(request, cancellationToken); #else throw new NotImplementedException("unreachable"); @@ -609,7 +609,7 @@ private async Task SendAsyncCore(HttpRequestMessage request protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) => SendAsyncCore(request, async: true, cancellationToken); -#if NET5_0_OR_GREATER +#if NET protected override HttpResponseMessage Send(HttpRequestMessage request, CancellationToken cancellationToken) => SendAsyncCore(request, async: false, cancellationToken).GetAwaiter().GetResult(); #endif diff --git a/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/LoggingUriOutputTests.cs b/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/LoggingUriOutputTests.cs index 8f6ca7a8c4e285..bdd204f709df39 100644 --- a/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/LoggingUriOutputTests.cs +++ b/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/Logging/LoggingUriOutputTests.cs @@ -91,7 +91,7 @@ public async Task LoggingScopeHttpMessageHandler_LogsAbsoluteUri() Assert.Equal("HTTP GET http://api.example.com/search?term=Western%20Australia", message.Scope.ToString()); } -#if NET5_0_OR_GREATER +#if NET [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNetCore))] public void LoggingHttpMessageHandler_LogsAbsoluteUri_Sync() { diff --git a/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/SocketsHttpHandlerConfigurationTest.cs b/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/SocketsHttpHandlerConfigurationTest.cs index 4473917ff728f0..059557a0784a70 100644 --- a/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/SocketsHttpHandlerConfigurationTest.cs +++ b/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/SocketsHttpHandlerConfigurationTest.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 NET5_0_OR_GREATER +#if NET using System; using System.Collections.Generic; using System.Net; diff --git a/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/TestMessageHandler.cs b/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/TestMessageHandler.cs index 5cbb8eb168f302..6bf2050cbd15c5 100644 --- a/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/TestMessageHandler.cs +++ b/src/libraries/Microsoft.Extensions.Http/tests/Microsoft.Extensions.Http.Tests/TestMessageHandler.cs @@ -26,7 +26,7 @@ protected override Task SendAsync(HttpRequestMessage reques return Task.FromResult(response); } -#if NET5_0_OR_GREATER +#if NET protected override HttpResponseMessage Send(HttpRequestMessage request, CancellationToken cancellationToken) => _responseFactory(request); #endif } diff --git a/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/EmitterTests.cs b/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/EmitterTests.cs index af91cab872c88f..1f54faf77d7fef 100644 --- a/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/EmitterTests.cs +++ b/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/EmitterTests.cs @@ -24,8 +24,8 @@ public async Task TestEmitter() #pragma warning disable RS1035 // To allow using the File IO APIs inside the analyzer test foreach (var file in Directory.GetFiles("TestClasses")) { -#if NETCOREAPP3_1_OR_GREATER - sources.Add("#define NETCOREAPP3_1_OR_GREATER\n" + File.ReadAllText(file)); +#if NET + sources.Add("#define NET\n" + File.ReadAllText(file)); #else sources.Add(File.ReadAllText(file)); #endif @@ -46,7 +46,7 @@ public async Task TestEmitter() Assert.Empty(d); _ = Assert.Single(r); -#if NETCOREAPP3_1_OR_GREATER +#if NET string baseline = File.ReadAllText(@"Baselines/NetCoreApp/Validators.g.cs"); #else string baseline = File.ReadAllText(@"Baselines/NetFX/Validators.g.cs"); diff --git a/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/Generated/OptionsValidationTests.cs b/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/Generated/OptionsValidationTests.cs index 4f9770ce7a17ca..01519b780eba1e 100644 --- a/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/Generated/OptionsValidationTests.cs +++ b/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/Generated/OptionsValidationTests.cs @@ -186,7 +186,7 @@ public void RangeAttributeModelDoubleInvalid() [Fact] public void RangeAttributeModelDateValid() { -#if NETCOREAPP3_1_OR_GREATER +#if NET // Setting non-invariant culture to check that // attribute's "ParseLimitsInInvariantCulture" property // was set up correctly in the validator: diff --git a/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/Generated/Utils.cs b/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/Generated/Utils.cs index 7412374f18a56f..eb6bf661490995 100644 --- a/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/Generated/Utils.cs +++ b/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/Generated/Utils.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 NETCOREAPP3_1_OR_GREATER +#if NET using System.Linq; #endif using Microsoft.Extensions.Options; @@ -15,7 +15,7 @@ public static void VerifyValidateOptionsResult(ValidateOptionsResult vr, int exp { Assert.NotNull(vr); -#if NETCOREAPP3_1_OR_GREATER +#if NET var failures = vr.Failures!.ToArray(); #else var failures = vr.FailureMessage!.Split(';'); diff --git a/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/TestClasses/Models.cs b/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/TestClasses/Models.cs index c245ebd783bdcf..bc76114ab62944 100644 --- a/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/TestClasses/Models.cs +++ b/src/libraries/Microsoft.Extensions.Options/tests/SourceGenerationTests/TestClasses/Models.cs @@ -76,7 +76,7 @@ public class RangeAttributeModelDouble public class RangeAttributeModelDate { -#if NETCOREAPP3_1_OR_GREATER +#if NET [Range(typeof(DateTime), "1/2/2004", "3/4/2004", ParseLimitsInInvariantCulture = true)] #else [Range(typeof(DateTime), "1/2/2004", "3/4/2004")] diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/Constants.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/Constants.cs index 5371a0354aeac6..ed797f8fae7bba 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/Constants.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/Constants.cs @@ -61,19 +61,13 @@ public static bool IsKnownComparable() => typeof(T) == typeof(DateTime) || typeof(T) == typeof(DateTimeOffset) || typeof(T) == typeof(Guid) || -#if NETCOREAPP3_0_OR_GREATER +#if NET typeof(T) == typeof(Rune) || -#endif -#if NET5_0_OR_GREATER typeof(T) == typeof(Half) || typeof(T) == typeof(nint) || typeof(T) == typeof(nuint) || -#endif -#if NET6_0_OR_GREATER typeof(T) == typeof(DateOnly) || typeof(T) == typeof(TimeOnly) || -#endif -#if NET7_0_OR_GREATER typeof(T) == typeof(Int128) || typeof(T) == typeof(UInt128) || #endif diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenHashTable.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenHashTable.cs index afb4785147391f..2bda7b2c76e70a 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenHashTable.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenHashTable.cs @@ -159,7 +159,7 @@ private static int CalcNumBuckets(ReadOnlySpan hashCodes, bool hashCodesAre if (!hashCodesAreUnique) { codes = -#if NETCOREAPP2_0_OR_GREATER +#if NET new HashSet(hashCodes.Length); #else new HashSet(); diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenSet.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenSet.cs index 50bbdeb18aad64..79acea67bd100c 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenSet.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenSet.cs @@ -202,7 +202,7 @@ private static FrozenSet CreateFromSet(HashSet source) [DebuggerTypeProxy(typeof(ImmutableEnumerableDebuggerProxy<>))] [DebuggerDisplay("Count = {Count}")] public abstract class FrozenSet : ISet, -#if NET5_0_OR_GREATER +#if NET IReadOnlySet, #endif IReadOnlyCollection, ICollection 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 208cf88c6ea62d..0793b3d12f7315 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 @@ -64,7 +64,7 @@ private static bool TryUseSubstring(ReadOnlySpan uniqueStrings, bool all new JustifiedCaseInsensitiveSubstringComparer(); HashSet set = new HashSet( -#if NET6_0_OR_GREATER +#if NET uniqueStrings.Length, #endif comparer); diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/LengthBuckets.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/LengthBuckets.cs index 97659c5479365c..626b21a8bf1212 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/LengthBuckets.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/LengthBuckets.cs @@ -28,7 +28,7 @@ internal static class LengthBuckets } int arraySize = spread * MaxPerLength; -#if NET6_0_OR_GREATER +#if NET if (arraySize > Array.MaxLength) #else if (arraySize > 0X7FFFFFC7) @@ -87,7 +87,7 @@ internal static class LengthBuckets return null; } -#if NET6_0_OR_GREATER +#if NET // We don't need an array with every value initialized to zero if we are just about to overwrite every value anyway. int[] copy = GC.AllocateUninitializedArray(arraySize); Array.Copy(buckets, copy, arraySize); diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Builder.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Builder.cs index 060492a40bd06e..459a3889d30af8 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Builder.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Builder.cs @@ -589,7 +589,7 @@ public void RemoveRange(int index, int length) if (index + length < this._count) { -#if NET6_0_OR_GREATER +#if NET if (RuntimeHelpers.IsReferenceOrContainsReferences()) { Array.Clear(_elements, index, length); // Clear the elements so that the gc can reclaim the references. @@ -919,7 +919,7 @@ public int LastIndexOf(T item, int startIndex, int count, IEqualityComparer? /// public void Reverse() { -#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER +#if NET || NETSTANDARD2_1_OR_GREATER Array.Reverse(_elements, 0, _count); #else // The non-generic Array.Reverse is not used because it does not perform @@ -963,7 +963,7 @@ public void Sort(Comparison comparison) if (Count > 1) { -#if NET6_0_OR_GREATER +#if NET // MemoryExtensions.Sort is not available in .NET Framework / Standard 2.0. // But the overload with a Comparison argument doesn't allocate. _elements.AsSpan(0, _count).Sort(comparison); diff --git a/src/libraries/System.Collections.Immutable/src/System/Polyfills.cs b/src/libraries/System.Collections.Immutable/src/System/Polyfills.cs index 77f304f46fdcd8..eeb82f0960ccc4 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Polyfills.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Polyfills.cs @@ -6,7 +6,7 @@ namespace System.Collections.Generic { -#if !NETCOREAPP2_0_OR_GREATER +#if !NET internal static class KeyValuePairExtensions { [EditorBrowsable(EditorBrowsableState.Never)] @@ -18,7 +18,7 @@ public static void Deconstruct(this KeyValuePair sou } #endif -#if !NET5_0_OR_GREATER +#if !NET internal interface IReadOnlySet : IReadOnlyCollection { bool Contains(T item); @@ -34,7 +34,7 @@ internal interface IReadOnlySet : IReadOnlyCollection namespace System.Numerics { -#if !NETCOREAPP3_0_OR_GREATER +#if !NET internal static class BitOperations { [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -45,7 +45,7 @@ internal static class BitOperations namespace System.Runtime.CompilerServices { -#if !NETCOREAPP3_0_OR_GREATER +#if !NET [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] internal sealed class CallerArgumentExpressionAttribute : Attribute { diff --git a/src/libraries/System.Collections.Immutable/tests/Frozen/FrozenSetTests.cs b/src/libraries/System.Collections.Immutable/tests/Frozen/FrozenSetTests.cs index 2558f9bedcd895..717efc31e45bb3 100644 --- a/src/libraries/System.Collections.Immutable/tests/Frozen/FrozenSetTests.cs +++ b/src/libraries/System.Collections.Immutable/tests/Frozen/FrozenSetTests.cs @@ -297,7 +297,7 @@ private sealed class InvertingComparer : IEqualityComparer private sealed class EmptySet : ISet -#if NET5_0_OR_GREATER +#if NET , IReadOnlySet #endif { diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ImplicitMachineConfigHost.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ImplicitMachineConfigHost.cs index 32403a8950c2c2..195b3ca5ff4a38 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ImplicitMachineConfigHost.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ImplicitMachineConfigHost.cs @@ -81,7 +81,7 @@ public override Stream OpenStreamForRead(string streamName)
" + -#if NET7_0_OR_GREATER +#if NET @"
" + #endif @"
diff --git a/src/libraries/System.Data.OleDb/src/DbConnectionOptions.cs b/src/libraries/System.Data.OleDb/src/DbConnectionOptions.cs index 0bb5bde47ea416..81b4ecdc5b7175 100644 --- a/src/libraries/System.Data.OleDb/src/DbConnectionOptions.cs +++ b/src/libraries/System.Data.OleDb/src/DbConnectionOptions.cs @@ -59,7 +59,7 @@ internal partial class DbConnectionOptions private static readonly Regex ConnectionStringRegex = CreateConnectionStringRegex(); private static readonly Regex ConnectionStringRegexOdbc = CreateConnectionStringRegexOdbc(); -#if NET7_0_OR_GREATER +#if NET [GeneratedRegex(ConnectionStringPattern, RegexOptions.ExplicitCapture)] private static partial Regex CreateConnectionStringRegex(); @@ -76,7 +76,7 @@ internal partial class DbConnectionOptions private static readonly Regex ConnectionStringQuoteValueRegex = CreateConnectionStringQuoteValueRegex(); // generally do not quote the value if it matches the pattern private static readonly Regex ConnectionStringQuoteOdbcValueRegex = CreateConnectionStringQuoteOdbcValueRegex(); // do not quote odbc value if it matches this pattern -#if NET7_0_OR_GREATER +#if NET [GeneratedRegex("^(?![;\\s])[^\\p{Cc}]+(? flagsChars = stackalloc char[2]; HexConverter.ToCharsBuffer((byte)((~ActivityTraceFlagsIsSet) & _w3CIdFlags), flagsChars, 0, HexConverter.Casing.Lower); string id = -#if NET6_0_OR_GREATER +#if NET string.Create(null, stackalloc char[128], $"00-{_traceId}-{_spanId}-{flagsChars}"); #else "00-" + _traceId + "-" + _spanId + "-" + flagsChars.ToString(); @@ -258,7 +258,7 @@ public string? ParentId Span flagsChars = stackalloc char[2]; HexConverter.ToCharsBuffer((byte)((~ActivityTraceFlagsIsSet) & _parentTraceFlags), flagsChars, 0, HexConverter.Casing.Lower); string parentId = -#if NET6_0_OR_GREATER +#if NET string.Create(null, stackalloc char[128], $"00-{_traceId}-{_parentSpanId}-{flagsChars}"); #else "00-" + _traceId + "-" + _parentSpanId + "-" + flagsChars.ToString(); diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/CounterAggregator.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/CounterAggregator.cs index b9e3c8d35bca70..4577c16b9b988e 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/CounterAggregator.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/CounterAggregator.cs @@ -33,7 +33,7 @@ public override void Update(double value) // Get the delta best associated with the current thread, preferring to use core ID rather than // thread ID to reduce contention. ref PaddedDouble delta = ref deltas[ -#if NETCOREAPP2_1_OR_GREATER +#if NET Thread.GetCurrentProcessorId() #else Environment.CurrentManagedThreadId diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/UnsafeNativeMethods.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/UnsafeNativeMethods.cs index e5cdb63f7ba76c..a8f8fd63369693 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/UnsafeNativeMethods.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/UnsafeNativeMethods.cs @@ -5,7 +5,7 @@ using System; using System.Diagnostics.Eventing.Reader; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.InteropServices.Marshalling; #endif using System.Security; @@ -341,7 +341,7 @@ internal enum EvtLoginClass EvtRpcLogin = 1 } -#if NET7_0_OR_GREATER +#if NET [NativeMarshalling(typeof(Marshaller))] #endif [StructLayout(LayoutKind.Sequential)] @@ -355,7 +355,7 @@ internal struct EvtRpcLogin public string Domain; public CoTaskMemUnicodeSafeHandle Password; public int Flags; -#if NET7_0_OR_GREATER +#if NET [CustomMarshaller(typeof(EvtRpcLogin), MarshalMode.ManagedToUnmanagedRef, typeof(ValueMarshaller))] public static class Marshaller { @@ -695,7 +695,7 @@ internal static partial bool EvtRender( out int buffUsed, out int propCount); -#if NET7_0_OR_GREATER +#if NET [NativeMarshalling(typeof(Marshaller))] #endif [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)] @@ -708,7 +708,7 @@ internal struct EvtStringVariant [FieldOffset(12)] public uint Type; -#if NET7_0_OR_GREATER +#if NET [CustomMarshaller(typeof(EvtStringVariant), MarshalMode.Default, typeof(Marshaller))] public static class Marshaller { diff --git a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.Integer.cs b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.Integer.cs index 102b05b82fb368..35372824d35e20 100644 --- a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.Integer.cs +++ b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.Integer.cs @@ -104,7 +104,7 @@ public static BigInteger ReadInteger( { ReadOnlySpan contents = ReadIntegerBytes(source, ruleSet, out int consumed, expectedTag); -#if NETCOREAPP2_1_OR_GREATER +#if NET BigInteger value = new BigInteger(contents, isBigEndian: true); #else byte[] tmp = CryptoPool.Rent(contents.Length); diff --git a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnWriter.Integer.cs b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnWriter.Integer.cs index 389196c0acd261..b1720b5106b2cd 100644 --- a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnWriter.Integer.cs +++ b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnWriter.Integer.cs @@ -281,7 +281,7 @@ private void WriteIntegerCore(Asn1Tag tag, BigInteger value) Debug.Assert(!tag.IsConstructed); WriteTag(tag); -#if NETCOREAPP2_1_OR_GREATER +#if NET WriteLength(value.GetByteCount()); // WriteLength ensures the content-space value.TryWriteBytes(_buffer.AsSpan(_offset), out int bytesWritten, isBigEndian: true); diff --git a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/SetOfValueComparer.cs b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/SetOfValueComparer.cs index 44b6c3030957e8..d766b5008c324c 100644 --- a/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/SetOfValueComparer.cs +++ b/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/SetOfValueComparer.cs @@ -17,7 +17,7 @@ internal static int Compare(ReadOnlySpan x, ReadOnlySpan y) int min = Math.Min(x.Length, y.Length); int diff; -#if NET7_0_OR_GREATER +#if NET int diffIndex = x.CommonPrefixLength(y); if (diffIndex != min) diff --git a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc32.cs b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc32.cs index 3a844a60637b07..260bf0bdadb374 100644 --- a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc32.cs +++ b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc32.cs @@ -169,7 +169,7 @@ public static uint HashToUInt32(ReadOnlySpan source) => private static uint Update(uint crc, ReadOnlySpan source) { -#if NET7_0_OR_GREATER +#if NET if (CanBeVectorized(source)) { return UpdateVectorized(crc, source); @@ -181,7 +181,7 @@ private static uint Update(uint crc, ReadOnlySpan source) private static uint UpdateScalar(uint crc, ReadOnlySpan source) { -#if NET6_0_OR_GREATER +#if NET // Use ARM intrinsics for CRC if available. This is used for the trailing bytes on the vectorized path // and is the primary method if the vectorized path is unavailable. if (System.Runtime.Intrinsics.Arm.Crc32.Arm64.IsSupported) diff --git a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc64.cs b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc64.cs index e9993a7503e787..89b81c657c518c 100644 --- a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc64.cs +++ b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc64.cs @@ -167,7 +167,7 @@ public static ulong HashToUInt64(ReadOnlySpan source) => private static ulong Update(ulong crc, ReadOnlySpan source) { -#if NET7_0_OR_GREATER +#if NET if (CanBeVectorized(source)) { return UpdateVectorized(crc, source); diff --git a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/XxHash128.cs b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/XxHash128.cs index fdfd24a60ab1f4..e1181cb73f914d 100644 --- a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/XxHash128.cs +++ b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/XxHash128.cs @@ -17,7 +17,7 @@ namespace System.IO.Hashing /// For methods that persist the computed numerical hash value as bytes, /// the value is written in the Big Endian byte order. /// -#if NET5_0_OR_GREATER +#if NET [SkipLocalsInit] #endif public sealed unsafe class XxHash128 : NonCryptographicHashAlgorithm @@ -51,7 +51,7 @@ public XxHash128(long seed) : base(HashLengthInBytes) /// is null. public static byte[] Hash(byte[] source, long seed) { -#if NET6_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(source); #else if (source is null) @@ -110,7 +110,7 @@ public static bool TryHash(ReadOnlySpan source, Span destination, ou return false; } -#if NET7_0_OR_GREATER +#if NET /// Computes the XXH128 hash of the provided data. /// The data to hash. /// The seed value for this hash computation. The default is zero. @@ -197,7 +197,7 @@ private Hash128 GetCurrentHashAsHash128() return current; } -#if NET7_0_OR_GREATER +#if NET /// Gets the current computed hash value without modifying accumulated state. /// The hash value for the data already provided. [CLSCompliant(false)] diff --git a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/XxHash3.cs b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/XxHash3.cs index 702409b949d451..affdfe78d6a850 100644 --- a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/XxHash3.cs +++ b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/XxHash3.cs @@ -16,7 +16,7 @@ namespace System.IO.Hashing /// For methods that persist the computed numerical hash value as bytes, /// the value is written in the Big Endian byte order. /// -#if NET5_0_OR_GREATER +#if NET [SkipLocalsInit] #endif public sealed unsafe class XxHash3 : NonCryptographicHashAlgorithm @@ -50,7 +50,7 @@ public XxHash3(long seed) : base(HashLengthInBytes) /// is null. public static byte[] Hash(byte[] source, long seed) { -#if NET6_0_OR_GREATER +#if NET ArgumentNullException.ThrowIfNull(source); #else if (source is null) diff --git a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/XxHashShared.cs b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/XxHashShared.cs index bfdf1963ac3b02..cafa80dbbf112e 100644 --- a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/XxHashShared.cs +++ b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/XxHashShared.cs @@ -6,7 +6,7 @@ using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER +#if NET using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.X86; @@ -15,7 +15,7 @@ namespace System.IO.Hashing { /// Shared implementation of the XXH3 hash algorithm for 64-bit in and version. -#if NET5_0_OR_GREATER +#if NET [SkipLocalsInit] #endif internal static unsafe class XxHashShared @@ -333,7 +333,7 @@ public static void CopyAccumulators(ref State state, ulong* accumulators) { fixed (ulong* stateAccumulators = state.Accumulators) { -#if NET7_0_OR_GREATER +#if NET if (Vector256.IsHardwareAccelerated) { Vector256.Store(Vector256.Load(stateAccumulators), accumulators); @@ -390,7 +390,7 @@ public static void DigestLong(ref State state, ulong* accumulators, byte* secret [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void InitializeAccumulators(ulong* accumulators) { -#if NET7_0_OR_GREATER +#if NET if (Vector256.IsHardwareAccelerated) { Vector256.Store(Vector256.Create(Prime32_3, Prime64_1, Prime64_2, Prime64_3), accumulators); @@ -452,7 +452,7 @@ public static ulong Avalanche(ulong hash) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong Multiply64To128(ulong left, ulong right, out ulong lower) { -#if NET5_0_OR_GREATER +#if NET return Math.BigMul(left, right, out lower); #else ulong lowerLow = Multiply32To64((uint)left, (uint)right); @@ -479,7 +479,7 @@ public static void DeriveSecretFromSeed(byte* destinationSecret, ulong seed) { fixed (byte* defaultSecret = &MemoryMarshal.GetReference(DefaultSecret)) { -#if NET7_0_OR_GREATER +#if NET if (Vector256.IsHardwareAccelerated && BitConverter.IsLittleEndian) { Vector256 seedVec = Vector256.Create(seed, 0u - seed, seed, 0u - seed); @@ -515,7 +515,7 @@ private static void Accumulate(ulong* accumulators, byte* source, byte* secret, byte* secretForAccumulate = secret; byte* secretForScramble = secret + (SecretLengthBytes - StripeLengthBytes); -#if NET7_0_OR_GREATER +#if NET if (Vector256.IsHardwareAccelerated && BitConverter.IsLittleEndian) { Vector256 acc1 = Vector256.Load(accumulators); @@ -620,7 +620,7 @@ public static void Accumulate512(ulong* accumulators, byte* source, byte* secret [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void Accumulate512Inlined(ulong* accumulators, byte* source, byte* secret) { -#if NET7_0_OR_GREATER +#if NET if (Vector256.IsHardwareAccelerated && BitConverter.IsLittleEndian) { for (int i = 0; i < AccumulatorCount / Vector256.Count; i++) @@ -659,7 +659,7 @@ private static void Accumulate512Inlined(ulong* accumulators, byte* source, byte } } -#if NET7_0_OR_GREATER +#if NET [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector256 Accumulate256(Vector256 accVec, byte* source, Vector256 secret) { @@ -714,7 +714,7 @@ private static Vector128 MultiplyWideningLower(Vector128 source) private static void ScrambleAccumulators(ulong* accumulators, byte* secret) { -#if NET7_0_OR_GREATER +#if NET if (Vector256.IsHardwareAccelerated && BitConverter.IsLittleEndian) { for (int i = 0; i < AccumulatorCount / Vector256.Count; i++) @@ -752,7 +752,7 @@ private static void ScrambleAccumulators(ulong* accumulators, byte* secret) } } -#if NET7_0_OR_GREATER +#if NET [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector256 ScrambleAccumulator256(Vector256 accVec, Vector256 secret) { diff --git a/src/libraries/System.IO.Hashing/tests/NonCryptoHashTestDriver.cs b/src/libraries/System.IO.Hashing/tests/NonCryptoHashTestDriver.cs index f2d8e411533ec7..fe17c4c14eab87 100644 --- a/src/libraries/System.IO.Hashing/tests/NonCryptoHashTestDriver.cs +++ b/src/libraries/System.IO.Hashing/tests/NonCryptoHashTestDriver.cs @@ -420,7 +420,7 @@ public LargeTestCase(string name, byte data, long repeatCount, string outputHex) public IEnumerable> EnumerateDataChunks() { -#if NET5_0_OR_GREATER +#if NET byte[] chunk = GC.AllocateUninitializedArray(1024 * 1024); #else byte[] chunk = new byte[1024 * 1024]; diff --git a/src/libraries/System.IO.Hashing/tests/XxHash128Tests.cs b/src/libraries/System.IO.Hashing/tests/XxHash128Tests.cs index 8d32a6f06c1d2d..3ba2044d069505 100644 --- a/src/libraries/System.IO.Hashing/tests/XxHash128Tests.cs +++ b/src/libraries/System.IO.Hashing/tests/XxHash128Tests.cs @@ -41,7 +41,7 @@ public void Hash_OneShot_Expected() Assert.Equal(expectedHash128, ReadHashBigEndian(XxHash128.Hash(input, test.Seed))); Assert.Equal(expectedHash128, ReadHashBigEndian(XxHash128.Hash((ReadOnlySpan)input, test.Seed))); -#if NET7_0_OR_GREATER +#if NET // Validate `XxHash128.HashToUInt128` Assert.Equal(new UInt128(test.HashHigh, test.HashLow), XxHash128.HashToUInt128(input, test.Seed)); #endif @@ -110,7 +110,7 @@ public void Hash_Streaming_Expected() // Validate that the hash we get from doing a one-shot of all the data up to this point // matches the incremental hash for the data appended until now. -#if NET7_0_OR_GREATER +#if NET Assert.Equal(XxHash128.HashToUInt128(asciiBytes.AsSpan(0, processed), test.Seed), hash.GetCurrentHashAsUInt128()); #endif Assert.True(hash.TryGetCurrentHash(destination, out int bytesWritten)); @@ -120,7 +120,7 @@ public void Hash_Streaming_Expected() } // Validate the final hash code. -#if NET7_0_OR_GREATER +#if NET Assert.Equal(new UInt128(test.HashHigh, test.HashLow), hash.GetCurrentHashAsUInt128()); #endif Array.Clear(destination, 0, destination.Length); diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/InternalRelationshipCollection.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/InternalRelationshipCollection.cs index b2ace96c807391..d76b0972d017ce 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/InternalRelationshipCollection.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/InternalRelationshipCollection.cs @@ -320,7 +320,7 @@ private void ProcessRelationshipAttributes(XmlCompatibilityReader reader) { try { -#if NET6_0_OR_GREATER +#if NET relationshipTargetMode = Enum.Parse(targetModeAttributeValue, ignoreCase: false); #else relationshipTargetMode = (TargetMode)(Enum.Parse(typeof(TargetMode), targetModeAttributeValue, ignoreCase: false)); diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackUriHelper.PackUriScheme.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackUriHelper.PackUriScheme.cs index 2707afbf4b5391..8bf3d1e5a0e8b5 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackUriHelper.PackUriScheme.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackUriHelper.PackUriScheme.cs @@ -285,7 +285,7 @@ private static string EscapeSpecialCharacters(string path) // This is currently enforced by the order of characters in the s_specialCharacterChars array foreach (char c in s_specialCharacterChars) { -#if NET5_0_OR_GREATER +#if NET if (path.Contains(c)) #else if (path.IndexOf(c) != -1) diff --git a/src/libraries/System.IO.Pipelines/tests/PipeReaderCopyToAsyncTests.cs b/src/libraries/System.IO.Pipelines/tests/PipeReaderCopyToAsyncTests.cs index 21228b2a1bf726..3c524de5122365 100644 --- a/src/libraries/System.IO.Pipelines/tests/PipeReaderCopyToAsyncTests.cs +++ b/src/libraries/System.IO.Pipelines/tests/PipeReaderCopyToAsyncTests.cs @@ -349,7 +349,7 @@ public override void Write(byte[] buffer, int offset, int count) Check(count); base.Write(buffer, offset, count); } -#if NETCOREAPP3_0_OR_GREATER +#if NET public override void Write(ReadOnlySpan buffer) { Check(buffer.Length); diff --git a/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialPort.cs b/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialPort.cs index 752163fd2bd379..426eb77d637d5b 100644 --- a/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialPort.cs +++ b/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialPort.cs @@ -963,7 +963,7 @@ public string ReadExisting() Buffer.BlockCopy(_inBuffer, _readPos, bytesReceived, 0, CachedBytesToRead); } -#if NET7_0_OR_GREATER +#if NET _internalSerialStream.ReadExactly(bytesReceived, CachedBytesToRead, bytesReceived.Length - CachedBytesToRead); // get everything #else int readCount = bytesReceived.Length - CachedBytesToRead; diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/StreamExtensions.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/StreamExtensions.cs index bb52925254c277..2bda7989a9bb9b 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/StreamExtensions.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/StreamExtensions.cs @@ -78,7 +78,7 @@ internal static int TryReadAll(this Stream stream, byte[] buffer, int offset, in #if NETCOREAPP internal static int TryReadAll(this Stream stream, Span buffer) -#if NET7_0_OR_GREATER +#if NET => stream.ReadAtLeast(buffer, buffer.Length, throwOnEndOfStream: false); #else { 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 d172f20f1cb066..cc8e5f3ce1ad23 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 @@ -134,7 +134,7 @@ public static bool NeedsEscapingInTypeName(this char c) public static string UnescapeTypeNameIdentifier(this string identifier) { -#if NET5_0_OR_GREATER +#if NET if (identifier.Contains('\\')) #else if (identifier.IndexOf('\\') != -1) diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoType.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoType.cs index 50ab6b7f307a08..1a5369f2f638d1 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoType.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoType.cs @@ -331,7 +331,7 @@ public sealed override Type MakeArrayType(int rank) private volatile RoType? _lazyUnderlyingEnumType; public sealed override Array GetEnumValues() => throw new InvalidOperationException(SR.Arg_InvalidOperation_Reflection); -#if NET7_0_OR_GREATER +#if NET [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2085:UnrecognizedReflectionPattern", Justification = "Enum Types are not trimmed.")] public override Array GetEnumValuesAsUnderlyingType() diff --git a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Type/TypeTests.cs b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Type/TypeTests.cs index 03611db20825a4..c476213963544a 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Type/TypeTests.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Type/TypeTests.cs @@ -365,7 +365,7 @@ public static IEnumerable GetEnumUnderlyingTypeData } } -#if NET7_0_OR_GREATER +#if NET [Fact] public static void GetEnumValuesAsUnderlyingType() { 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 6351a376c0bc72..b26ff355f378e8 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 @@ -364,7 +364,7 @@ public static string ToSerialString(this byte[] serialBytes) return ToUpperHexString(serialBytes); } -#if NET5_0_OR_GREATER +#if NET private static string ToUpperHexString(ReadOnlySpan ba) { return Convert.ToHexString(ba); diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Utils.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Utils.cs index ffffeefa5bac37..de7bc2b9b77b7e 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Utils.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Utils.cs @@ -720,7 +720,7 @@ internal static X509Certificate2Collection BuildBagOfCerts(KeyInfoX509Data keyIn return collection; } -#if NET5_0_OR_GREATER +#if NET internal static string EncodeHexString(byte[] sArray) { return Convert.ToHexString(sArray); diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlResolverHelper.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlResolverHelper.cs index 3070ffa8e1d233..948f883b80a2eb 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlResolverHelper.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlResolverHelper.cs @@ -11,14 +11,14 @@ internal static class XmlResolverHelper { internal static XmlResolver GetThrowingResolver() { -#if NET7_0_OR_GREATER +#if NET return XmlResolver.ThrowingResolver; #else return XmlThrowingResolver.s_singleton; #endif } -#if !NET7_0_OR_GREATER +#if !NET // An XmlResolver that forbids all external entity resolution. // (Copied from XmlResolver.ThrowingResolver.cs.) private sealed class XmlThrowingResolver : XmlResolver diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/XmlBuffer.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/XmlBuffer.cs index 17f3cfa2e1e7ad..4c31f32bf505a2 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/XmlBuffer.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/XmlBuffer.cs @@ -87,7 +87,7 @@ public void Close() _buffer = new byte[_stream.Length]; _stream.Position = 0; -#if NET7_0_OR_GREATER +#if NET _stream.ReadExactly(_buffer); #else int totalRead = 0; diff --git a/src/libraries/System.Speech/src/Internal/Synthesis/AudioBase.cs b/src/libraries/System.Speech/src/Internal/Synthesis/AudioBase.cs index 782cd59fb6c34c..c8ecfa78483570 100644 --- a/src/libraries/System.Speech/src/Internal/Synthesis/AudioBase.cs +++ b/src/libraries/System.Speech/src/Internal/Synthesis/AudioBase.cs @@ -122,7 +122,7 @@ internal void PlayWaveFile(AudioData audio) { byte[] data = new byte[(int)audio._stream.Length]; -#if NET7_0_OR_GREATER +#if NET audio._stream.ReadExactly(data); #else int totalRead = 0; diff --git a/src/libraries/System.Speech/src/Internal/Synthesis/EngineSite.cs b/src/libraries/System.Speech/src/Internal/Synthesis/EngineSite.cs index a658f37ca6180b..c6caca4d9c25bf 100644 --- a/src/libraries/System.Speech/src/Internal/Synthesis/EngineSite.cs +++ b/src/libraries/System.Speech/src/Internal/Synthesis/EngineSite.cs @@ -175,7 +175,7 @@ public Stream LoadResource(Uri uri, string mediaType) MemoryStream memStream = new(cLen); byte[] ab = new byte[cLen]; -#if NET7_0_OR_GREATER +#if NET stream.ReadExactly(ab); #else int totalRead = 0; diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/CodePagesEncodingProvider.cs b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/CodePagesEncodingProvider.cs index c984dbf460d8a4..58bb679c7712ae 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/CodePagesEncodingProvider.cs +++ b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/CodePagesEncodingProvider.cs @@ -197,7 +197,7 @@ public static EncodingProvider Instance internal static unsafe ref T GetNonNullPinnableReference(T[] array) where T : struct { return ref -#if NET5_0_OR_GREATER +#if NET MemoryMarshal.GetArrayDataReference(array); #else array.Length != 0 ? ref array[0] : ref Unsafe.AsRef((void*)1); diff --git a/src/libraries/System.Text.Json/Common/JsonHelpers.cs b/src/libraries/System.Text.Json/Common/JsonHelpers.cs index 5711afa8370689..afa3afb4dc2ce4 100644 --- a/src/libraries/System.Text.Json/Common/JsonHelpers.cs +++ b/src/libraries/System.Text.Json/Common/JsonHelpers.cs @@ -55,7 +55,7 @@ internal static bool RequiresSpecialNumberHandlingOnWrite(JsonNumberHandling? ha internal static void StableSortByKey(this List items, Func keySelector) where TKey : unmanaged, IComparable { -#if NET6_0_OR_GREATER +#if NET Span span = CollectionsMarshal.AsSpan(items); // Tuples implement lexical ordering OOTB which can be used to encode stable sorting diff --git a/src/libraries/System.Text.Json/ref/System.Text.Json.netcoreapp.cs b/src/libraries/System.Text.Json/ref/System.Text.Json.netcoreapp.cs index 847da900ad35d8..bbf2e3846a6bcd 100644 --- a/src/libraries/System.Text.Json/ref/System.Text.Json.netcoreapp.cs +++ b/src/libraries/System.Text.Json/ref/System.Text.Json.netcoreapp.cs @@ -12,7 +12,7 @@ public static partial class JsonMetadataServices public static System.Text.Json.Serialization.JsonConverter HalfConverter { get { throw null; } } public static System.Text.Json.Serialization.JsonConverter TimeOnlyConverter { get { throw null; } } -#if NET7_0_OR_GREATER +#if NET public static System.Text.Json.Serialization.JsonConverter Int128Converter { get { throw null; } } [System.CLSCompliantAttribute(false)] public static System.Text.Json.Serialization.JsonConverter UInt128Converter { get { throw null; } } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.MetadataDb.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.MetadataDb.cs index afdbf4bd0b9b26..a53df982c12eb4 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.MetadataDb.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocument.MetadataDb.cs @@ -240,7 +240,7 @@ private void Enlarge() // Note: Array.MaxLength exists only on .NET 6 or greater, // so for the other versions value is hardcoded const int MaxArrayLength = 0x7FFFFFC7; -#if NET6_0_OR_GREATER +#if NET Debug.Assert(MaxArrayLength == Array.MaxLength); #endif diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/JsonConstants.cs b/src/libraries/System.Text.Json/src/System/Text/Json/JsonConstants.cs index 7fe47499c1aa85..c2dbc58e131a0c 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/JsonConstants.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/JsonConstants.cs @@ -65,7 +65,7 @@ internal static partial class JsonConstants // When transcoding from UTF8 -> UTF16, the byte count threshold where we rent from the array pool before performing a normal alloc. public const long ArrayPoolMaxSizeBeforeUsingNormalAlloc = -#if NET6_0_OR_GREATER +#if NET 1024 * 1024 * 1024; // ArrayPool limit increased in .NET 6 #else 1024 * 1024; diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.MultiSegment.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.MultiSegment.cs index 8635031292e32c..22d3cc1c497d81 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.MultiSegment.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.MultiSegment.cs @@ -633,7 +633,7 @@ private static int FindMismatch(ReadOnlySpan span, ReadOnlySpan lite int indexOfFirstMismatch; -#if NET7_0_OR_GREATER +#if NET indexOfFirstMismatch = span.CommonPrefixLength(literal); #else int minLength = Math.Min(span.Length, literal.Length); diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/DefaultJsonTypeInfoResolver.Converters.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/DefaultJsonTypeInfoResolver.Converters.cs index 117e3ba3d63a97..b5bb76c77b0652 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/DefaultJsonTypeInfoResolver.Converters.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/DefaultJsonTypeInfoResolver.Converters.cs @@ -74,7 +74,7 @@ private static Dictionary GetDefaultSimpleConverters() Add(JsonMetadataServices.UInt16Converter); Add(JsonMetadataServices.UInt32Converter); Add(JsonMetadataServices.UInt64Converter); -#if NET7_0_OR_GREATER +#if NET Add(JsonMetadataServices.Int128Converter); Add(JsonMetadataServices.UInt128Converter); #endif diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonMetadataServices.Converters.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonMetadataServices.Converters.cs index 83a24191b8fe25..1cf87d0c940e7a 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonMetadataServices.Converters.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonMetadataServices.Converters.cs @@ -108,7 +108,7 @@ public static partial class JsonMetadataServices public static JsonConverter Int64Converter => s_int64Converter ??= new Int64Converter(); private static JsonConverter? s_int64Converter; -#if NET7_0_OR_GREATER +#if NET /// /// Returns a instance that converts values. /// diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPropertyInfo.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPropertyInfo.cs index 959490b53f19fc..e70cd8848868af 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPropertyInfo.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPropertyInfo.cs @@ -626,7 +626,7 @@ private bool NumberHandingIsApplicable() #if NETCOREAPP potentialNumberType == typeof(Half) || #endif -#if NET7_0_OR_GREATER +#if NET potentialNumberType == typeof(Int128) || potentialNumberType == typeof(UInt128) || #endif diff --git a/src/libraries/System.Text.Json/tests/Common/CollectionTests/CollectionTests.Dictionary.NonStringKey.cs b/src/libraries/System.Text.Json/tests/Common/CollectionTests/CollectionTests.Dictionary.NonStringKey.cs index dfaff9130fa78a..ce8ac3d254d3ac 100644 --- a/src/libraries/System.Text.Json/tests/Common/CollectionTests/CollectionTests.Dictionary.NonStringKey.cs +++ b/src/libraries/System.Text.Json/tests/Common/CollectionTests/CollectionTests.Dictionary.NonStringKey.cs @@ -46,7 +46,7 @@ public static IEnumerable GetTestDictionaries() yield return WrapArgs(DateTime.MaxValue, 1, expectedJson: $@"{{""{DateTime.MaxValue:O}"":1}}"); yield return WrapArgs(DateTimeOffset.MaxValue, 1, expectedJson: $@"{{""{DateTimeOffset.MaxValue:O}"":1}}"); yield return WrapArgs(TimeSpan.MaxValue, 1, expectedJson: $@"{{""{TimeSpan.MaxValue}"":1}}"); -#if NET6_0_OR_GREATER +#if NET yield return WrapArgs(DateOnly.MaxValue, 1, expectedJson: $@"{{""{DateOnly.MaxValue:O}"":1}}"); yield return WrapArgs(TimeOnly.MaxValue, 1, expectedJson: $@"{{""{TimeOnly.MaxValue:O}"":1}}"); #endif diff --git a/src/libraries/System.Text.Json/tests/Common/TestClasses/TestClasses.cs b/src/libraries/System.Text.Json/tests/Common/TestClasses/TestClasses.cs index 9f8af715fdb8e4..92c12b1dfc44c9 100644 --- a/src/libraries/System.Text.Json/tests/Common/TestClasses/TestClasses.cs +++ b/src/libraries/System.Text.Json/tests/Common/TestClasses/TestClasses.cs @@ -1907,7 +1907,7 @@ public override void WriteAsPropertyName(Utf8JsonWriter writer, int value, JsonS public static class ReflectionExtensions { -#if NET6_0_OR_GREATER +#if NET [return: System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] public static Type WithConstructors( [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCharClass.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCharClass.cs index 5666498347e468..3c24bdc78ad06f 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCharClass.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCharClass.cs @@ -563,7 +563,7 @@ public static string ConvertOldStringsToClass(string set, string category) } return -#if NETCOREAPP2_1_OR_GREATER +#if NET string #else StringExtensions @@ -1304,7 +1304,7 @@ static bool InitializeValue(char ch, string set, ref uint[]? asciiLazyCache) } uint[]? cache = asciiLazyCache ?? Interlocked.CompareExchange(ref asciiLazyCache, new uint[CacheArrayLength], null) ?? asciiLazyCache; -#if NET5_0_OR_GREATER +#if NET Interlocked #else InterlockedExtensions @@ -1594,7 +1594,7 @@ internal static unsafe string CharsToStringClass(ReadOnlySpan chars) #pragma warning disable CS8500 // takes address of managed type ReadOnlySpan tmpChars = chars; // avoid address exposing the span and impacting the other code in the method that uses it return -#if NETCOREAPP2_1_OR_GREATER +#if NET string #else StringExtensions diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexWriter.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexWriter.cs index 5284c09339bd7b..4d779d4f48f127 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexWriter.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexWriter.cs @@ -177,7 +177,7 @@ private void Emit(RegexOpcode op, int opd1, int opd2) ///
private int StringCode(string str) { -#if NET6_0_OR_GREATER +#if NET ref int i = ref CollectionsMarshal.GetValueRefOrAddDefault(_stringTable, str, out bool exists); if (!exists) { diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Threading/StackHelper.cs b/src/libraries/System.Text.RegularExpressions/src/System/Threading/StackHelper.cs index c338c2bb73e95c..ded50c662ea4a4 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Threading/StackHelper.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Threading/StackHelper.cs @@ -12,7 +12,7 @@ internal static class StackHelper /// Tries to ensure there is sufficient stack to execute the average .NET function. public static bool TryEnsureSufficientExecutionStack() { -#if NETCOREAPP2_0_OR_GREATER +#if NET return RuntimeHelpers.TryEnsureSufficientExecutionStack(); #else try diff --git a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs index 9d3679be60b938..234b416a9b46de 100644 --- a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs +++ b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs @@ -1327,7 +1327,7 @@ public void Match_InstanceMethods_DefaultTimeout_Throws(RegexEngine engine) }, ((int)engine).ToString(CultureInfo.InvariantCulture)).Dispose(); } -#if NET7_0_OR_GREATER +#if NET [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] public void Match_InstanceMethods_DefaultTimeout_SourceGenerated_Throws() { @@ -1885,7 +1885,7 @@ public async Task Match_StartatDiffersFromBeginning(RegexEngine engine, string p Regex r = await RegexHelpers.GetRegexAsync(engine, pattern, options); Assert.Equal(expectedSuccessStartAt, r.IsMatch(input, startat)); -#if NET7_0_OR_GREATER +#if NET Assert.Equal(expectedSuccessStartAt, r.IsMatch(input.AsSpan(), startat)); #endif @@ -2069,7 +2069,7 @@ public async Task TestCharIsLowerCultureEdgeCasesAroundTurkishCharacters(RegexEn Regex r1 = await RegexHelpers.GetRegexAsync(engine, "[\u012F-\u0130]", RegexOptions.IgnoreCase); Regex r2 = await RegexHelpers.GetRegexAsync(engine, "[\u012F\u0130]", RegexOptions.IgnoreCase); Assert.Equal(r1.IsMatch("\u0130"), r2.IsMatch("\u0130")); -#if NET7_0_OR_GREATER +#if NET Assert.Equal(r1.IsMatch("\u0130".AsSpan()), r2.IsMatch("\u0130".AsSpan())); #endif @@ -2491,14 +2491,14 @@ private static void VerifyIsMatchThrows(Regex? r, string input, TimeSpan time if (r == null) { Assert.Throws(() => timeout == Regex.InfiniteMatchTimeout ? Regex.IsMatch(input, pattern, options) : Regex.IsMatch(input, pattern, options, timeout)); -#if NET7_0_OR_GREATER +#if NET Assert.Throws(() => timeout == Regex.InfiniteMatchTimeout ? Regex.IsMatch(input.AsSpan(), pattern, options) : Regex.IsMatch(input.AsSpan(), pattern, options, timeout)); #endif } else { Assert.Throws(() => r.IsMatch(input)); -#if NET7_0_OR_GREATER +#if NET Assert.Throws(() => r.IsMatch(input.AsSpan())); #endif } @@ -2513,7 +2513,7 @@ private static void VerifyIsMatch(Regex? r, string input, bool expected, TimeSpa { Assert.Equal(expected, Regex.IsMatch(input, pattern)); } -#if NET7_0_OR_GREATER +#if NET Assert.Equal(expected, timeout == Regex.InfiniteMatchTimeout ? Regex.IsMatch(input.AsSpan(), pattern, options) : Regex.IsMatch(input.AsSpan(), pattern, options, timeout)); if (options == RegexOptions.None) { @@ -2524,7 +2524,7 @@ private static void VerifyIsMatch(Regex? r, string input, bool expected, TimeSpa else { Assert.Equal(expected, r.IsMatch(input)); -#if NET7_0_OR_GREATER +#if NET Assert.Equal(expected, r.IsMatch(input.AsSpan())); #endif } diff --git a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Tests.Common.cs b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Tests.Common.cs index 4d4f2252839ae5..b0a9b6549492bc 100644 --- a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Tests.Common.cs +++ b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Tests.Common.cs @@ -187,7 +187,7 @@ public static async Task GetRegexesAsync(RegexEngine engine, params (st /// Set the AppContext variable REGEX_NONBACKTRACKING_MAX_AUTOMATA_SIZE to the given max value. Only used with Nonbacktracking engine. public static void SetSafeSizeThreshold(int maxSize) { -#if NET7_0_OR_GREATER +#if NET AppContext.SetData("REGEX_NONBACKTRACKING_MAX_AUTOMATA_SIZE", maxSize); #endif } @@ -195,7 +195,7 @@ public static void SetSafeSizeThreshold(int maxSize) /// Remove the AppContext variable REGEX_NONBACKTRACKING_MAX_AUTOMATA_SIZE value. Only used with Nonbacktracking engine. public static void RestoreSafeSizeThresholdToDefault() { -#if NET7_0_OR_GREATER +#if NET AppContext.SetData("REGEX_NONBACKTRACKING_MAX_AUTOMATA_SIZE", null); #endif } diff --git a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/RegexRunnerTests.cs b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/RegexRunnerTests.cs index d4cd665e5b1af9..0f5799687011cd 100644 --- a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/RegexRunnerTests.cs +++ b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/RegexRunnerTests.cs @@ -50,7 +50,7 @@ public async Task EnsureRunmatchValueIsNulledAfterIsMatch(RegexEngine engine) MethodInfo getTextMethod = typeof(Match).GetMethod("get_Text", BindingFlags.Instance | BindingFlags.NonPublic); Assert.Null(getTextMethod.Invoke(runmatch, [])); Assert.Equal(string.Empty, runmatch.Value); -#if NET7_0_OR_GREATER +#if NET Assert.True(runmatch.ValueSpan == ReadOnlySpan.Empty); #endif } diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlock.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlock.cs index 63cdedf4b466a6..c91cff3b5423ab 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlock.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlock.cs @@ -1470,7 +1470,7 @@ public static Task OutputAvailableAsync( { // When cancellation is requested, unlink the target from the source and cancel the target. target._ctr = cancellationToken.Register( -#if NET6_0_OR_GREATER +#if NET OutputAvailableAsyncTarget.CancelAndUnlink, #else static state => OutputAvailableAsyncTarget.CancelAndUnlink(state, default), diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/Common.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/Common.cs index 7bfd3ecf35d952..c04ee9556003d4 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/Common.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/Common.cs @@ -190,7 +190,7 @@ internal static void WireCancellationToComplete( // data, and we also want to dispose of that registration when we complete so that we don't // leak into a long-living cancellation token. CancellationTokenRegistration reg = cancellationToken.Register( -#if NET6_0_OR_GREATER +#if NET completeAction, completeState #else state => 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 d77919070c24df..e57dff3e55ce2a 100644 --- a/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs +++ b/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs @@ -314,7 +314,7 @@ private void LoadStream(bool loadSync) int streamLen = (int)_stream.Length; _currentPos = 0; _streamData = new byte[streamLen]; -#if NET7_0_OR_GREATER +#if NET _stream.ReadExactly(_streamData); #else int totalRead = 0; diff --git a/src/libraries/System.Windows.Extensions/src/System/Security/Cryptography/X509Certificates/X509Certificate2UI.cs b/src/libraries/System.Windows.Extensions/src/System/Security/Cryptography/X509Certificates/X509Certificate2UI.cs index b19e217322f07e..dfdb4660ea4991 100644 --- a/src/libraries/System.Windows.Extensions/src/System/Security/Cryptography/X509Certificates/X509Certificate2UI.cs +++ b/src/libraries/System.Windows.Extensions/src/System/Security/Cryptography/X509Certificates/X509Certificate2UI.cs @@ -53,7 +53,7 @@ private static unsafe void DisplayX509Certificate(X509Certificate2 certificate, // Initialize view structure. Interop.CryptUI.CRYPTUI_VIEWCERTIFICATE_STRUCTW ViewInfo = default; -#if NET7_0_OR_GREATER +#if NET ViewInfo.dwSize = (uint)sizeof(Interop.CryptUI.CRYPTUI_VIEWCERTIFICATE_STRUCTW.Marshaller.Native); #else ViewInfo.dwSize = (uint)Marshal.SizeOf(); @@ -122,7 +122,7 @@ private static unsafe SafeCertStoreHandle SelectFromStore(SafeCertStoreHandle sa Interop.CryptUI.CRYPTUI_SELECTCERTIFICATE_STRUCTW csc = default; // Older versions of CRYPTUI do not check the size correctly, // so always force it to the oldest version of the structure. -#if NET7_0_OR_GREATER +#if NET // Declare a local for Native to enable us to get the managed byte offset // without having a null check cause a failure. Interop.CryptUI.CRYPTUI_SELECTCERTIFICATE_STRUCTW.Marshaller.Native native; diff --git a/src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilConverter.cs b/src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilConverter.cs index 13c34bde4b8ea1..0a0495f72fef4e 100644 --- a/src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilConverter.cs +++ b/src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilConverter.cs @@ -213,7 +213,7 @@ private static void WriteSectionHeader(Stream s, WebcilSectionHeader sectionHead WriteStructure(s, sectionHeader); } -#if NETCOREAPP2_1_OR_GREATER +#if NET private static void WriteStructure(Stream s, T structure) where T : unmanaged { @@ -256,7 +256,7 @@ private static void CopySections(Stream outStream, FileStream inputStream, Immut } } -#if NETCOREAPP2_1_OR_GREATER +#if NET private static void ReadExactly(FileStream s, Span buffer) { s.ReadExactly(buffer); diff --git a/src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilWasmWrapper.cs b/src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilWasmWrapper.cs index 3f8560446306fb..f47a1247474784 100644 --- a/src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilWasmWrapper.cs +++ b/src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilWasmWrapper.cs @@ -63,7 +63,7 @@ public void WriteWasmWrappedWebcil(Stream outputStream) // // extracted by wasm-reader -s wrapper.wasm private static -#if NET7_0_OR_GREATER +#if NET ReadOnlyMemory #else byte[] @@ -80,7 +80,7 @@ private static // // extracted by wasm-reader -s wrapper.wasm private static -#if NET7_0_OR_GREATER +#if NET ReadOnlyMemory #else byte[] @@ -91,7 +91,7 @@ private static private static void WriteWasmHeader(Stream outputStream) { -#if NET7_0_OR_GREATER +#if NET outputStream.Write(s_wasmWrapperPrefix.Span); #else outputStream.Write(s_wasmWrapperPrefix, 0, s_wasmWrapperPrefix.Length); @@ -100,7 +100,7 @@ private static void WriteWasmHeader(Stream outputStream) private static void WriteWasmSuffix(Stream outputStream) { -#if NET7_0_OR_GREATER +#if NET outputStream.Write(s_wasmWrapperSuffix.Span); #else outputStream.Write(s_wasmWrapperSuffix, 0, s_wasmWrapperSuffix.Length); diff --git a/src/tests/tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouterFactory.cs b/src/tests/tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouterFactory.cs index 30ccdc1a48f4be..41726e9286791b 100644 --- a/src/tests/tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouterFactory.cs +++ b/src/tests/tracing/eventpipe/common/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouterFactory.cs @@ -136,7 +136,7 @@ protected async Task IsStreamConnectedAsync(Stream stream, CancellationToken tok protected bool IsCompletedSuccessfully(Task t) { -#if NETCOREAPP2_0_OR_GREATER +#if NET return t.IsCompletedSuccessfully; #else return t.IsCompleted && !t.IsCanceled && !t.IsFaulted;