diff --git a/CommunityToolkit.HighPerformance/Buffers/MemoryOwner{T}.cs b/CommunityToolkit.HighPerformance/Buffers/MemoryOwner{T}.cs index c2e5ea82..b172dc2a 100644 --- a/CommunityToolkit.HighPerformance/Buffers/MemoryOwner{T}.cs +++ b/CommunityToolkit.HighPerformance/Buffers/MemoryOwner{T}.cs @@ -6,7 +6,7 @@ using System.Buffers; using System.Diagnostics; using System.Runtime.CompilerServices; -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER using System.Runtime.InteropServices; #endif using CommunityToolkit.HighPerformance.Buffers.Views; @@ -171,13 +171,13 @@ public Span Span ThrowObjectDisposedException(); } -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER ref T r0 = ref array!.DangerousGetReferenceAt(this.start); - // On .NET Core runtimes, we can manually create a span from the starting reference to + // On .NET 6+ runtimes, we can manually create a span from the starting reference to // skip the argument validations, which include an explicit null check, covariance check // for the array and the actual validation for the starting offset and target length. We - // only do this on .NET Core as we can leverage the runtime-specific array layout to get + // only do this on .NET 6+ as we can leverage the runtime-specific array layout to get // a fast access to the initial element, which makes this trick worth it. Otherwise, on // runtimes where we would need to at least access a static field to retrieve the base // byte offset within an SZ array object, we can get better performance by just using the diff --git a/CommunityToolkit.HighPerformance/Buffers/SpanOwner{T}.cs b/CommunityToolkit.HighPerformance/Buffers/SpanOwner{T}.cs index f258f5f1..152260ea 100644 --- a/CommunityToolkit.HighPerformance/Buffers/SpanOwner{T}.cs +++ b/CommunityToolkit.HighPerformance/Buffers/SpanOwner{T}.cs @@ -6,7 +6,7 @@ using System.Buffers; using System.Diagnostics; using System.Runtime.CompilerServices; -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER using System.Runtime.InteropServices; #endif using CommunityToolkit.HighPerformance.Buffers.Views; @@ -141,7 +141,7 @@ public Span Span [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER ref T r0 = ref this.array!.DangerousGetReference(); return MemoryMarshal.CreateSpan(ref r0, this.length); diff --git a/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj b/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj index 03beef56..8ea177dd 100644 --- a/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj +++ b/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net7.0 + netstandard2.0;netstandard2.1;net6.0;net7.0 @@ -47,23 +47,11 @@ - + NETSTANDARD2_1_OR_GREATER - - - - NETSTANDARD2_1_OR_GREATER - - - - - - - \ No newline at end of file diff --git a/CommunityToolkit.HighPerformance/Extensions/ArrayExtensions.1D.cs b/CommunityToolkit.HighPerformance/Extensions/ArrayExtensions.1D.cs index 58186ff7..02699452 100644 --- a/CommunityToolkit.HighPerformance/Extensions/ArrayExtensions.1D.cs +++ b/CommunityToolkit.HighPerformance/Extensions/ArrayExtensions.1D.cs @@ -4,7 +4,7 @@ using System; using System.Runtime.CompilerServices; -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER using System.Runtime.InteropServices; #endif using CommunityToolkit.HighPerformance.Enumerables; @@ -33,11 +33,6 @@ public static ref T DangerousGetReference(this T[] array) { #if NET6_0_OR_GREATER return ref MemoryMarshal.GetArrayDataReference(array); -#elif NETCOREAPP3_1 - RawArrayData? arrayData = Unsafe.As(array)!; - ref T r0 = ref Unsafe.As(ref arrayData.Data); - - return ref r0; #else IntPtr offset = RuntimeHelpers.GetArrayDataByteOffset(); @@ -60,12 +55,6 @@ public static ref T DangerousGetReferenceAt(this T[] array, int i) ref T r0 = ref MemoryMarshal.GetArrayDataReference(array); ref T ri = ref Unsafe.Add(ref r0, (nint)(uint)i); - return ref ri; -#elif NETCOREAPP3_1 - RawArrayData? arrayData = Unsafe.As(array)!; - ref T r0 = ref Unsafe.As(ref arrayData.Data); - ref T ri = ref Unsafe.Add(ref r0, (nint)(uint)i); - return ref ri; #else IntPtr offset = RuntimeHelpers.GetArrayDataByteOffset(); @@ -76,26 +65,6 @@ public static ref T DangerousGetReferenceAt(this T[] array, int i) #endif } -#if NETCOREAPP3_1 - // Description taken from CoreCLR: see https://source.dot.net/#System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs,285. - // CLR arrays are laid out in memory as follows (multidimensional array bounds are optional): - // [ sync block || pMethodTable || num components || MD array bounds || array data .. ] - // ^ ^ ^ returned reference - // | \-- ref Unsafe.As(array).Data - // \-- array - // The base size of an array includes all the fields before the array data, - // including the sync block and method table. The reference to RawData.Data - // points at the number of components, skipping over these two pointer-sized fields. - [StructLayout(LayoutKind.Sequential)] - private sealed class RawArrayData - { -#pragma warning disable CS0649 // Unassigned fields - public IntPtr Length; - public byte Data; -#pragma warning restore CS0649 - } -#endif - /// /// Counts the number of occurrences of a given value into a target array instance. /// diff --git a/CommunityToolkit.HighPerformance/Extensions/ArrayExtensions.2D.cs b/CommunityToolkit.HighPerformance/Extensions/ArrayExtensions.2D.cs index e86af22f..dec994ab 100644 --- a/CommunityToolkit.HighPerformance/Extensions/ArrayExtensions.2D.cs +++ b/CommunityToolkit.HighPerformance/Extensions/ArrayExtensions.2D.cs @@ -30,11 +30,6 @@ public static ref T DangerousGetReference(this T[,] array) { #if NET6_0_OR_GREATER return ref Unsafe.As(ref MemoryMarshal.GetArrayDataReference(array)); -#elif NETCOREAPP3_1 - RawArray2DData? arrayData = Unsafe.As(array)!; - ref T r0 = ref Unsafe.As(ref arrayData.Data); - - return ref r0; #else IntPtr offset = RuntimeHelpers.GetArray2DDataByteOffset(); @@ -65,13 +60,6 @@ public static ref T DangerousGetReferenceAt(this T[,] array, int i, int j) ref T r0 = ref Unsafe.As(ref MemoryMarshal.GetArrayDataReference(array)); ref T ri = ref Unsafe.Add(ref r0, index); - return ref ri; -#elif NETCOREAPP3_1 - RawArray2DData? arrayData = Unsafe.As(array)!; - nint offset = ((nint)(uint)i * (nint)(uint)arrayData.Width) + (nint)(uint)j; - ref T r0 = ref Unsafe.As(ref arrayData.Data); - ref T ri = ref Unsafe.Add(ref r0, offset); - return ref ri; #else int width = array.GetLength(1); @@ -84,29 +72,6 @@ public static ref T DangerousGetReferenceAt(this T[,] array, int i, int j) #endif } -#if NETCOREAPP3_1 - // Description adapted from CoreCLR: see https://source.dot.net/#System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs,285. - // CLR 2D arrays are laid out in memory as follows: - // [ sync block || pMethodTable || Length (padded to IntPtr) || HxW || HxW bounds || array data .. ] - // ^ ^ - // | \-- ref Unsafe.As(array).Data - // \-- array - // The length is always padded to IntPtr just like with SZ arrays. - // The total data padding is therefore 20 bytes on x86 (4 + 4 + 4 + 4 + 4), or 24 bytes on x64. - [StructLayout(LayoutKind.Sequential)] - private sealed class RawArray2DData - { -#pragma warning disable CS0649 // Unassigned fields - public IntPtr Length; - public int Height; - public int Width; - public int HeightLowerBound; - public int WidthLowerBound; - public byte Data; -#pragma warning restore CS0649 - } -#endif - /// /// Returns a over a row in a given 2D array instance. /// diff --git a/CommunityToolkit.HighPerformance/Extensions/ArrayExtensions.3D.cs b/CommunityToolkit.HighPerformance/Extensions/ArrayExtensions.3D.cs index d6b72e53..2c02a323 100644 --- a/CommunityToolkit.HighPerformance/Extensions/ArrayExtensions.3D.cs +++ b/CommunityToolkit.HighPerformance/Extensions/ArrayExtensions.3D.cs @@ -29,11 +29,6 @@ public static ref T DangerousGetReference(this T[,,] array) { #if NET6_0_OR_GREATER return ref Unsafe.As(ref MemoryMarshal.GetArrayDataReference(array)); -#elif NETCOREAPP3_1 - RawArray3DData? arrayData = Unsafe.As(array)!; - ref T r0 = ref Unsafe.As(ref arrayData.Data); - - return ref r0; #else IntPtr offset = RuntimeHelpers.GetArray3DDataByteOffset(); @@ -68,15 +63,6 @@ public static ref T DangerousGetReferenceAt(this T[,,] array, int i, int j, i ref T r0 = ref Unsafe.As(ref MemoryMarshal.GetArrayDataReference(array)); ref T ri = ref Unsafe.Add(ref r0, index); - return ref ri; -#elif NETCOREAPP3_1 - RawArray3DData? arrayData = Unsafe.As(array)!; - nint offset = - ((nint)(uint)i * (nint)(uint)arrayData.Height * (nint)(uint)arrayData.Width) + - ((nint)(uint)j * (nint)(uint)arrayData.Width) + (nint)(uint)k; - ref T r0 = ref Unsafe.As(ref arrayData.Data); - ref T ri = ref Unsafe.Add(ref r0, offset); - return ref ri; #else int height = array.GetLength(1); @@ -92,25 +78,6 @@ public static ref T DangerousGetReferenceAt(this T[,,] array, int i, int j, i #endif } -#if NETCOREAPP3_1 - // See description for this in the 2D partial file. - // Using the CHW naming scheme here (like with RGB images). - [StructLayout(LayoutKind.Sequential)] - private sealed class RawArray3DData - { -#pragma warning disable CS0649 // Unassigned fields - public IntPtr Length; - public int Channel; - public int Height; - public int Width; - public int ChannelLowerBound; - public int HeightLowerBound; - public int WidthLowerBound; - public byte Data; -#pragma warning restore CS0649 - } -#endif - #if NETSTANDARD2_1_OR_GREATER /// /// Creates a new over an input 3D array. diff --git a/CommunityToolkit.HighPerformance/Extensions/StringExtensions.cs b/CommunityToolkit.HighPerformance/Extensions/StringExtensions.cs index 6c464e9c..a3260c5b 100644 --- a/CommunityToolkit.HighPerformance/Extensions/StringExtensions.cs +++ b/CommunityToolkit.HighPerformance/Extensions/StringExtensions.cs @@ -26,7 +26,7 @@ public static class StringExtensions [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref char DangerousGetReference(this string text) { -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER return ref Unsafe.AsRef(text.GetPinnableReference()); #else return ref MemoryMarshal.GetReference(text.AsSpan()); @@ -43,7 +43,7 @@ public static ref char DangerousGetReference(this string text) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref char DangerousGetReferenceAt(this string text, int i) { -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER ref char r0 = ref Unsafe.AsRef(text.GetPinnableReference()); #else ref char r0 = ref MemoryMarshal.GetReference(text.AsSpan()); diff --git a/CommunityToolkit.HighPerformance/Helpers/BitHelper.cs b/CommunityToolkit.HighPerformance/Helpers/BitHelper.cs index b4af97f6..30e6405f 100644 --- a/CommunityToolkit.HighPerformance/Helpers/BitHelper.cs +++ b/CommunityToolkit.HighPerformance/Helpers/BitHelper.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER using System.Runtime.Intrinsics.X86; #endif @@ -224,7 +224,7 @@ public static unsafe uint SetFlag(uint value, int n, bool flag) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint ExtractRange(uint value, byte start, byte length) { -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER if (Bmi1.IsSupported) { return Bmi1.BitFieldExtract(value, start, length); @@ -270,7 +270,7 @@ public static uint SetRange(uint value, byte start, byte length, uint flags) uint loadMask = highBits << start; uint storeMask = (flags & highBits) << start; -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER if (Bmi1.IsSupported) { return Bmi1.AndNot(loadMask, value) | storeMask; @@ -386,7 +386,7 @@ public static unsafe ulong SetFlag(ulong value, int n, bool flag) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong ExtractRange(ulong value, byte start, byte length) { -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER if (Bmi1.X64.IsSupported) { return Bmi1.X64.BitFieldExtract(value, start, length); @@ -432,7 +432,7 @@ public static ulong SetRange(ulong value, byte start, byte length, ulong flags) ulong loadMask = highBits << start; ulong storeMask = (flags & highBits) << start; -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER if (Bmi1.X64.IsSupported) { return Bmi1.X64.AndNot(loadMask, value) | storeMask; diff --git a/CommunityToolkit.HighPerformance/Helpers/Internals/BitOperations.cs b/CommunityToolkit.HighPerformance/Helpers/Internals/BitOperations.cs index b2ec8f71..d802529c 100644 --- a/CommunityToolkit.HighPerformance/Helpers/Internals/BitOperations.cs +++ b/CommunityToolkit.HighPerformance/Helpers/Internals/BitOperations.cs @@ -5,10 +5,6 @@ #if !NET6_0_OR_GREATER using System.Runtime.CompilerServices; -#if NETCOREAPP3_1 -using System.Runtime.Intrinsics.X86; -using static System.Numerics.BitOperations; -#endif namespace CommunityToolkit.HighPerformance.Helpers.Internals; @@ -29,22 +25,6 @@ internal static class BitOperations [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe uint RoundUpToPowerOf2(uint value) { -#if NETCOREAPP3_1 - if (Lzcnt.IsSupported) - { - if (sizeof(nint) == 8) - { - return (uint)(0x1_0000_0000ul >> LeadingZeroCount(value - 1)); - } - else - { - int shift = 32 - LeadingZeroCount(value - 1); - - return (1u ^ (uint)(shift >> 5)) << shift; - } - } -#endif - // Based on https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 --value; value |= value >> 1; diff --git a/CommunityToolkit.HighPerformance/Helpers/Internals/RuntimeHelpers.cs b/CommunityToolkit.HighPerformance/Helpers/Internals/RuntimeHelpers.cs index c08d327c..be66eb9f 100644 --- a/CommunityToolkit.HighPerformance/Helpers/Internals/RuntimeHelpers.cs +++ b/CommunityToolkit.HighPerformance/Helpers/Internals/RuntimeHelpers.cs @@ -75,7 +75,7 @@ public static nint GetArrayNativeLength(Array array) return (nint)array.LongLength; } -#if !NETCOREAPP3_1_OR_GREATER +#if !NET6_0_OR_GREATER /// /// Gets the byte offset to the first element in a SZ array. /// diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 45fda4c7..4738052b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -53,14 +53,14 @@ jobs: # Test solution # + # Run .NET 7 unit tests + - script: dotnet test --no-build -c $(Build.Configuration) -f net7.0 -l "trx;LogFileName=VSTestResults_net7.0.trx" + displayName: Run .NET 7 unit tests + # Run .NET 6 unit tests - script: dotnet test --no-build -c $(Build.Configuration) -f net6.0 -l "trx;LogFileName=VSTestResults_net6.0.trx" displayName: Run .NET 6 unit tests - # Run .NET Core 3.1 unit tests - - script: dotnet test --no-build -c $(Build.Configuration) -f netcoreapp3.1 -l "trx;LogFileName=VSTestResults_netcoreapp3.1.trx" - displayName: Run .NET Core 3.1 unit tests - # Run .NET Framework 4.7.2 unit tests - script: dotnet test --no-build -c $(Build.Configuration) -f net472 -l "trx;LogFileName=VSTestResults_net472.trx" displayName: Run .NET Framework 4.7.2 unit tests diff --git a/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj b/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj index e0c1ec2a..aab3e610 100644 --- a/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj +++ b/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp3.1;net6.0 + net472;net6.0;net7.0 diff --git a/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj b/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj index bb9d02a4..a17ec571 100644 --- a/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj +++ b/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp3.1;net6.0 + net472;net6.0;net7.0 diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_StringPool.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_StringPool.cs index 915b21ef..08a3715a 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_StringPool.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Buffers/Test_StringPool.cs @@ -217,7 +217,7 @@ public void Test_StringPool_GetOrAdd_ReadOnlySpan_Misc() Assert.AreEqual(nameof(helloworld), helloworld); Assert.AreEqual(nameof(dotnetCommunityToolkit), dotnetCommunityToolkit); -#if NETCOREAPP +#if NET6_0_OR_GREATER // .NET Framework reuses strings in a way that makes these tests fail. // The actual underlying APIs are still working as expected though. diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj b/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj index 8a5d750b..23dcf7ae 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/CommunityToolkit.HighPerformance.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp3.1;net6.0;net7.0 + net472;net6.0;net7.0 true $(NoWarn);CA2252 diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Enumerables/Test_ReadOnlyRefEnumerable{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Enumerables/Test_ReadOnlyRefEnumerable{T}.cs index 7623fb0c..9012fcab 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Enumerables/Test_ReadOnlyRefEnumerable{T}.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Enumerables/Test_ReadOnlyRefEnumerable{T}.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if NETCOREAPP +#if NET6_0_OR_GREATER using System; using System.Runtime.CompilerServices; @@ -81,7 +81,7 @@ public void Test_ReadOnlyRefEnumerable_Indexer_ThrowsIndexOutOfRange() _ = Assert.ThrowsException(() => ReadOnlyRefEnumerable.DangerousCreate(in array[0], array.Length, 1)[array.Length]); } -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER [TestMethod] [DataRow(1, new[] { 1 })] [DataRow(1, new[] { 1, 2, 3, 4 })] diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Enumerables/Test_RefEnumerable{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Enumerables/Test_RefEnumerable{T}.cs index 2763e1cb..6deb4afc 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Enumerables/Test_RefEnumerable{T}.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Enumerables/Test_RefEnumerable{T}.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if NETCOREAPP +#if NET6_0_OR_GREATER using System; using System.Runtime.CompilerServices; @@ -81,7 +81,7 @@ public void Test_RefEnumerable_Indexer_ThrowsIndexOutOfRange() _ = Assert.ThrowsException(() => RefEnumerable.DangerousCreate(ref array[0], array.Length, 1)[array.Length]); } -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER [TestMethod] [DataRow(1, new[] { 1 })] [DataRow(1, new[] { 1, 2, 3, 4 })] diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ArrayExtensions.2D.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ArrayExtensions.2D.cs index 44fb8aad..5d41cf9b 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ArrayExtensions.2D.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ArrayExtensions.2D.cs @@ -419,7 +419,7 @@ public void Test_ArrayExtensions_2D_GetColumn_Empty() _ = Assert.ThrowsException(() => array.GetColumn(0).ToArray()); } -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER [TestMethod] public void Test_ArrayExtensions_2D_AsSpan_Empty() { diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_IBufferWriterExtensions.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_IBufferWriterExtensions.cs index 63696d90..c7f94bb3 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_IBufferWriterExtensions.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_IBufferWriterExtensions.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System; -#if NETCOREAPP +#if NET6_0_OR_GREATER using System.Buffers; #endif using System.IO; diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Internals/Test_RuntimeHelpers.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Internals/Test_RuntimeHelpers.cs index 0d741f7d..640d3a70 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Internals/Test_RuntimeHelpers.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Internals/Test_RuntimeHelpers.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if !NETCOREAPP3_1_OR_GREATER +#if !NET6_0_OR_GREATER using System; using CommunityToolkit.HighPerformance.Helpers.Internals; diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_HashCode{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_HashCode{T}.cs index 36029a2a..4191acac 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_HashCode{T}.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_HashCode{T}.cs @@ -55,7 +55,7 @@ public void Test_HashCodeOfT_VectorUnsupportedTypes_TestRepeat() TestForType(); } -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER [TestMethod] public void Test_HashCodeOfT_ManagedType_TestRepeat() { diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.For.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.For.cs index 7890c83a..15252760 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.For.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.For.cs @@ -38,7 +38,7 @@ public unsafe void Test_ParallelHelper_ForWithIndices() } } -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER [TestMethod] [ExpectedException(typeof(ArgumentException))] public void Test_ParallelHelper_ForInvalidRange_FromEnd() diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.For2D.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.For2D.cs index 6226967f..157b6a4a 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.For2D.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Helpers/Test_ParallelHelper.For2D.cs @@ -50,7 +50,7 @@ public unsafe void Test_ParallelHelper_For2DWithIndices() } } -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER [TestMethod] [ExpectedException(typeof(ArgumentException))] public void Test_ParallelHelper_For2DInvalidRange_FromEnd() diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_Memory2D{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_Memory2D{T}.cs index 028a2162..d1e36587 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_Memory2D{T}.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_Memory2D{T}.cs @@ -194,7 +194,7 @@ public void Test_Memory2DT_Array3DConstructor_2() _ = Assert.ThrowsException(() => new Memory2D(array, 0, 0, 0, 3, 3)); } -#if NETCOREAPP +#if NET6_0_OR_GREATER [TestMethod] public void Test_Memory2DT_MemoryConstructor() { @@ -352,7 +352,7 @@ public void Test_Memory2DT_TryGetMemory_2() Assert.AreEqual(memory.Span[2], 3); } -#if NETCOREAPP +#if NET6_0_OR_GREATER [TestMethod] public void Test_Memory2DT_TryGetMemory_3() { diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_ReadOnlyMemory2D{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_ReadOnlyMemory2D{T}.cs index fda5cd9b..55cafefc 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_ReadOnlyMemory2D{T}.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_ReadOnlyMemory2D{T}.cs @@ -174,7 +174,7 @@ public void Test_ReadOnlyMemory2DT_Array3DConstructor_2() _ = Assert.ThrowsException(() => new ReadOnlyMemory2D(array, 0, 0, 0, 3, 3)); } -#if NETCOREAPP +#if NET6_0_OR_GREATER [TestMethod] public void Test_ReadOnlyMemory2DT_ReadOnlyMemoryConstructor() { @@ -316,7 +316,7 @@ public void Test_ReadOnlyMemory2DT_TryGetReadOnlyMemory_2() Assert.AreEqual(memory.Span[2], 3); } -#if NETCOREAPP +#if NET6_0_OR_GREATER [TestMethod] public void Test_ReadOnlyMemory2DT_TryGetReadOnlyMemory_3() { diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_ReadOnlySpan2D{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_ReadOnlySpan2D{T}.cs index 5c4ce173..2b527c18 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_ReadOnlySpan2D{T}.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_ReadOnlySpan2D{T}.cs @@ -35,7 +35,7 @@ public void Test_ReadOnlySpan2DT_Empty() Assert.AreEqual(empty2.Height, 0); } -#if NETCOREAPP +#if NET6_0_OR_GREATER [TestMethod] public unsafe void Test_ReadOnlySpan2DT_RefConstructor() { @@ -386,7 +386,7 @@ ref Unsafe.AsRef(null), Assert.IsTrue(Unsafe.AreSame(ref r0, ref array[0, 0])); } -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER [TestMethod] public unsafe void Test_ReadOnlySpan2DT_Index_Indexer_1() { @@ -535,7 +535,7 @@ public void Test_ReadOnlySpan2DT_Slice_2() Assert.AreEqual(slice3[0, 0], 5); } -#if NETCOREAPP +#if NET6_0_OR_GREATER [TestMethod] public void Test_ReadOnlySpan2DT_GetRowReadOnlySpan() { diff --git a/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_Span2D{T}.cs b/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_Span2D{T}.cs index 05f0946e..15be6300 100644 --- a/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_Span2D{T}.cs +++ b/tests/CommunityToolkit.HighPerformance.UnitTests/Memory/Test_Span2D{T}.cs @@ -46,7 +46,7 @@ public void Test_Span2DT_Empty() Assert.AreEqual(empty4.Height, 0); } -#if NETCOREAPP +#if NET6_0_OR_GREATER [TestMethod] public unsafe void Test_Span2DT_RefConstructor() { @@ -546,7 +546,7 @@ ref Unsafe.AsRef(null), Assert.IsTrue(Unsafe.AreSame(ref r0, ref array[0, 0])); } -#if NETCOREAPP3_1_OR_GREATER +#if NET6_0_OR_GREATER [TestMethod] public unsafe void Test_Span2DT_Index_Indexer_1() { @@ -700,7 +700,7 @@ public void Test_Span2DT_Slice_2() Assert.AreEqual(slice3[0, 0], 5); } -#if NETCOREAPP +#if NET6_0_OR_GREATER [TestMethod] public void Test_Span2DT_GetRowSpan() { diff --git a/tests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests.csproj index d74d2ea4..d839207f 100644 --- a/tests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests/CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp3.1;net6.0 + net472;net6.0;net7.0 diff --git a/tests/CommunityToolkit.Mvvm.Internals.UnitTests/CommunityToolkit.Mvvm.Internals.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.Internals.UnitTests/CommunityToolkit.Mvvm.Internals.UnitTests.csproj index 3e43daf6..3c9546fd 100644 --- a/tests/CommunityToolkit.Mvvm.Internals.UnitTests/CommunityToolkit.Mvvm.Internals.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.Internals.UnitTests/CommunityToolkit.Mvvm.Internals.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp3.1;net6.0 + net472;net6.0;net7.0 diff --git a/tests/CommunityToolkit.Mvvm.Internals.UnitTests/Test_Messenger.cs b/tests/CommunityToolkit.Mvvm.Internals.UnitTests/Test_Messenger.cs index 22fd1dd6..70f5408c 100644 --- a/tests/CommunityToolkit.Mvvm.Internals.UnitTests/Test_Messenger.cs +++ b/tests/CommunityToolkit.Mvvm.Internals.UnitTests/Test_Messenger.cs @@ -14,7 +14,7 @@ namespace CommunityToolkit.Mvvm.Internals.UnitTests; [TestClass] public partial class Test_Messenger { -#if NETCOREAPP // Auto-trimming is disabled on .NET Framework +#if NET6_0_OR_GREATER // Auto-trimming is disabled on .NET Framework [TestMethod] public void Test_WeakReferenceMessenger_AutoCleanup() { diff --git a/tests/CommunityToolkit.Mvvm.Roslyn401.UnitTests/CommunityToolkit.Mvvm.Roslyn401.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.Roslyn401.UnitTests/CommunityToolkit.Mvvm.Roslyn401.UnitTests.csproj index d1a2f483..75d2a7af 100644 --- a/tests/CommunityToolkit.Mvvm.Roslyn401.UnitTests/CommunityToolkit.Mvvm.Roslyn401.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.Roslyn401.UnitTests/CommunityToolkit.Mvvm.Roslyn401.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp3.1;net6.0 + net472;net6.0;net7.0 true diff --git a/tests/CommunityToolkit.Mvvm.Roslyn431.UnitTests/CommunityToolkit.Mvvm.Roslyn431.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.Roslyn431.UnitTests/CommunityToolkit.Mvvm.Roslyn431.UnitTests.csproj index 9e32846d..3d84adb3 100644 --- a/tests/CommunityToolkit.Mvvm.Roslyn431.UnitTests/CommunityToolkit.Mvvm.Roslyn431.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.Roslyn431.UnitTests/CommunityToolkit.Mvvm.Roslyn431.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp3.1;net6.0 + net472;net6.0;net7.0 true diff --git a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn401.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn401.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn401.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn401.UnitTests.csproj index d3038433..d36020ac 100644 --- a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn401.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn401.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn401.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn401.UnitTests.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp3.1;net6.0 + net472;net6.0;net7.0 diff --git a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn431.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn431.UnitTests.csproj b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn431.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn431.UnitTests.csproj index f0c5ad5d..37ec37d3 100644 --- a/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn431.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn431.UnitTests.csproj +++ b/tests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn431.UnitTests/CommunityToolkit.Mvvm.SourceGenerators.Roslyn431.UnitTests.csproj @@ -1,7 +1,7 @@ - + - net472;netcoreapp3.1;net6.0 + net472;net6.0;net7.0 diff --git a/tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Helpers/CSharpAnalyzerWithLanguageVersionTest{TAnalyzer}.cs b/tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Helpers/CSharpAnalyzerWithLanguageVersionTest{TAnalyzer}.cs index 211ab92b..a2610aad 100644 --- a/tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Helpers/CSharpAnalyzerWithLanguageVersionTest{TAnalyzer}.cs +++ b/tests/CommunityToolkit.Mvvm.SourceGenerators.UnitTests/Helpers/CSharpAnalyzerWithLanguageVersionTest{TAnalyzer}.cs @@ -50,10 +50,8 @@ public static Task VerifyAnalyzerAsync(string source, LanguageVersion languageVe { CSharpAnalyzerWithLanguageVersionTest test = new(languageVersion) { TestCode = source }; -#if NET6_0 +#if NET6_0_OR_GREATER test.TestState.ReferenceAssemblies = ReferenceAssemblies.Net.Net60; -#elif NETCOREAPP3_1 - test.TestState.ReferenceAssemblies = ReferenceAssemblies.NetCore.NetCoreApp31; #else test.TestState.ReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default; test.TestState.AdditionalReferences.Add(MetadataReference.CreateFromFile(typeof(RequiredAttribute).Assembly.Location));