From 77149455ba27fd149593e155541617e73e4cfb06 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 5 Nov 2025 13:21:22 -0800 Subject: [PATCH] Update codebase to target .NET 8.0 and remove .NET 7.0 Replaces all conditional compilation checks for NET7_0_OR_GREATER with NET8_0_OR_GREATER and removes .NET 7.0 from the target frameworks in the project file. This ensures the codebase is aligned with .NET 8.0 features and APIs, simplifying maintenance and leveraging the latest platform improvements. --- .../CommunityToolkit.HighPerformance.csproj | 2 +- .../Enumerables/ReadOnlyRefEnumerable{T}.cs | 34 +++++++++--------- .../Enumerables/ReadOnlySpanEnumerable{T}.cs | 8 ++--- .../Enumerables/RefEnumerable{T}.cs | 36 +++++++++---------- .../Enumerables/SpanEnumerable{T}.cs | 8 ++--- .../Extensions/NullableExtensions.cs | 6 ++-- .../Extensions/SpinLockExtensions.cs | 2 +- .../Extensions/StreamExtensions.cs | 4 +-- .../Memory/ReadOnlySpan2D{T}.Enumerator.cs | 12 +++---- .../Memory/ReadOnlySpan2D{T}.cs | 32 ++++++++--------- .../Memory/Span2D{T}.Enumerator.cs | 12 +++---- .../Memory/Span2D{T}.cs | 32 ++++++++--------- .../NullableReadOnlyRef{T}.cs | 2 +- .../NullableRef{T}.cs | 2 +- .../ReadOnlyRef{T}.cs | 2 +- .../Ref{T}.cs | 2 +- 16 files changed, 98 insertions(+), 98 deletions(-) diff --git a/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj b/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj index 06972b24b..3d3477589 100644 --- a/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj +++ b/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1;net7.0;net8.0 + netstandard2.0;netstandard2.1;net8.0 diff --git a/src/CommunityToolkit.HighPerformance/Enumerables/ReadOnlyRefEnumerable{T}.cs b/src/CommunityToolkit.HighPerformance/Enumerables/ReadOnlyRefEnumerable{T}.cs index dcc9f0880..074a0cd22 100644 --- a/src/CommunityToolkit.HighPerformance/Enumerables/ReadOnlyRefEnumerable{T}.cs +++ b/src/CommunityToolkit.HighPerformance/Enumerables/ReadOnlyRefEnumerable{T}.cs @@ -21,7 +21,7 @@ namespace CommunityToolkit.HighPerformance.Enumerables; /// The type of items to enumerate. public readonly ref struct ReadOnlyRefEnumerable { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER /// /// The reference for the instance. /// @@ -61,7 +61,7 @@ public readonly ref struct ReadOnlyRefEnumerable private readonly int step; #if NETSTANDARD2_1_OR_GREATER -#if !NET7_0_OR_GREATER +#if !NET8_0_OR_GREATER /// /// Initializes a new instance of the struct. /// @@ -70,7 +70,7 @@ public readonly ref struct ReadOnlyRefEnumerable [MethodImpl(MethodImplOptions.AggressiveInlining)] private ReadOnlyRefEnumerable(ReadOnlySpan span, int step) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref MemoryMarshal.GetReference(span); this.length = span.Length; #else @@ -89,7 +89,7 @@ private ReadOnlyRefEnumerable(ReadOnlySpan span, int step) [MethodImpl(MethodImplOptions.AggressiveInlining)] internal ReadOnlyRefEnumerable(in T reference, int length, int step) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref reference; this.length = length; this.step = step; @@ -147,7 +147,7 @@ internal ReadOnlyRefEnumerable(object? instance, IntPtr offset, int length, int public int Length { [MethodImpl(MethodImplOptions.AggressiveInlining)] -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER get => this.length; #elif NETSTANDARD2_1_OR_GREATER get => this.span.Length; @@ -174,7 +174,7 @@ public ref readonly T this[int index] ThrowHelper.ThrowIndexOutOfRangeException(); } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER ref T r0 = ref Unsafe.AsRef(in this.reference); #elif NETSTANDARD2_1_OR_GREATER ref T r0 = ref MemoryMarshal.GetReference(this.span); @@ -208,7 +208,7 @@ public ref readonly T this[Index index] [MethodImpl(MethodImplOptions.AggressiveInlining)] public Enumerator GetEnumerator() { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return new(in this.reference, this.length, this.step); #elif NETSTANDARD2_1_OR_GREATER return new(this.span, this.step); @@ -226,7 +226,7 @@ public Enumerator GetEnumerator() /// public void CopyTo(RefEnumerable destination) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER if (this.step == 1) { destination.CopyFrom(MemoryMarshal.CreateReadOnlySpan(ref Unsafe.AsRef(in this.reference), this.length)); @@ -286,7 +286,7 @@ public void CopyTo(RefEnumerable destination) /// Whether or not the operation was successful. public bool TryCopyTo(RefEnumerable destination) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER int sourceLength = this.length; int destinationLength = destination.Length; #elif NETSTANDARD2_1_OR_GREATER @@ -316,7 +316,7 @@ public bool TryCopyTo(RefEnumerable destination) /// public void CopyTo(Span destination) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER if (this.step == 1) { MemoryMarshal.CreateReadOnlySpan(ref Unsafe.AsRef(in this.reference), this.length).CopyTo(destination); @@ -357,7 +357,7 @@ public void CopyTo(Span destination) /// Whether or not the operation was successful. public bool TryCopyTo(Span destination) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER int length = this.length; #elif NETSTANDARD2_1_OR_GREATER int length = this.span.Length; @@ -378,7 +378,7 @@ public bool TryCopyTo(Span destination) /// public T[] ToArray() { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER int length = this.length; #elif NETSTANDARD2_1_OR_GREATER int length = this.span.Length; @@ -406,7 +406,7 @@ public T[] ToArray() [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator ReadOnlyRefEnumerable(RefEnumerable enumerable) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return new(in enumerable.Reference, enumerable.Length, enumerable.Step); #elif NETSTANDARD2_1_OR_GREATER return new(enumerable.Span, enumerable.Step); @@ -420,7 +420,7 @@ public static implicit operator ReadOnlyRefEnumerable(RefEnumerable enumer /// public ref struct Enumerator { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER /// private readonly ref readonly T reference; @@ -448,7 +448,7 @@ public ref struct Enumerator /// private int position; -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER /// /// Initializes a new instance of the struct. /// @@ -499,7 +499,7 @@ internal Enumerator(object? instance, IntPtr offset, int length, int step) [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool MoveNext() { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return ++this.position < this.length; #elif NETSTANDARD2_1_OR_GREATER return ++this.position < this.span.Length; @@ -514,7 +514,7 @@ public readonly ref readonly T Current [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER ref T r0 = ref Unsafe.AsRef(in this.reference); #elif NETSTANDARD2_1_OR_GREATER ref T r0 = ref this.span.DangerousGetReference(); diff --git a/src/CommunityToolkit.HighPerformance/Enumerables/ReadOnlySpanEnumerable{T}.cs b/src/CommunityToolkit.HighPerformance/Enumerables/ReadOnlySpanEnumerable{T}.cs index 2f6b16a5b..c06d45249 100644 --- a/src/CommunityToolkit.HighPerformance/Enumerables/ReadOnlySpanEnumerable{T}.cs +++ b/src/CommunityToolkit.HighPerformance/Enumerables/ReadOnlySpanEnumerable{T}.cs @@ -81,7 +81,7 @@ public readonly Item Current [EditorBrowsable(EditorBrowsableState.Never)] public readonly ref struct Item { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER /// /// The reference for the instance. /// @@ -107,7 +107,7 @@ public readonly ref struct Item [MethodImpl(MethodImplOptions.AggressiveInlining)] public Item(ref T value, int index) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref value; this.index = index; #else @@ -141,7 +141,7 @@ public ref readonly T Value [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return ref this.reference; #elif NETSTANDARD2_1_OR_GREATER return ref MemoryMarshal.GetReference(this.span); @@ -162,7 +162,7 @@ public int Index [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return this.index; #elif NETSTANDARD2_1_OR_GREATER return this.span.Length; diff --git a/src/CommunityToolkit.HighPerformance/Enumerables/RefEnumerable{T}.cs b/src/CommunityToolkit.HighPerformance/Enumerables/RefEnumerable{T}.cs index a6fab2ab6..bdb508386 100644 --- a/src/CommunityToolkit.HighPerformance/Enumerables/RefEnumerable{T}.cs +++ b/src/CommunityToolkit.HighPerformance/Enumerables/RefEnumerable{T}.cs @@ -21,7 +21,7 @@ namespace CommunityToolkit.HighPerformance.Enumerables; /// The type of items to enumerate. public readonly ref struct RefEnumerable { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER /// /// The reference for the instance. /// @@ -65,7 +65,7 @@ public readonly ref struct RefEnumerable [MethodImpl(MethodImplOptions.AggressiveInlining)] internal RefEnumerable(ref T reference, int length, int step) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.Reference = ref reference; this.length = length; #else @@ -123,7 +123,7 @@ internal RefEnumerable(object? instance, IntPtr offset, int length, int step) public int Length { [MethodImpl(MethodImplOptions.AggressiveInlining)] -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER get => this.length; #elif NETSTANDARD2_1_OR_GREATER get => this.Span.Length; @@ -150,7 +150,7 @@ public ref T this[int index] ThrowHelper.ThrowIndexOutOfRangeException(); } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER ref T r0 = ref this.Reference; #elif NETSTANDARD2_1_OR_GREATER ref T r0 = ref MemoryMarshal.GetReference(this.Span); @@ -184,7 +184,7 @@ public ref T this[Index index] [MethodImpl(MethodImplOptions.AggressiveInlining)] public Enumerator GetEnumerator() { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return new(ref this.Reference, this.length, this.Step); #elif NETSTANDARD2_1_OR_GREATER return new(this.Span, this.Step); @@ -198,7 +198,7 @@ public Enumerator GetEnumerator() /// public void Clear() { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER // Fast path for contiguous items if (this.Step == 1) { @@ -236,7 +236,7 @@ public void Clear() /// public void CopyTo(RefEnumerable destination) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER if (this.Step == 1) { destination.CopyFrom(MemoryMarshal.CreateReadOnlySpan(ref this.Reference, this.length)); @@ -296,7 +296,7 @@ public void CopyTo(RefEnumerable destination) /// Whether or not the operation was successful. public bool TryCopyTo(RefEnumerable destination) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER int sourceLength = this.length; int destinationLength = destination.length; #elif NETSTANDARD2_1_OR_GREATER @@ -326,7 +326,7 @@ public bool TryCopyTo(RefEnumerable destination) /// public void CopyTo(Span destination) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER if (this.Step == 1) { MemoryMarshal.CreateReadOnlySpan(ref this.Reference, this.length).CopyTo(destination); @@ -367,7 +367,7 @@ public void CopyTo(Span destination) /// Whether or not the operation was successful. public bool TryCopyTo(Span destination) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER int length = this.length; #elif NETSTANDARD2_1_OR_GREATER int length = this.Span.Length; @@ -394,7 +394,7 @@ public bool TryCopyTo(Span destination) /// internal void CopyFrom(ReadOnlySpan source) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER if (this.Step == 1) { source.CopyTo(MemoryMarshal.CreateSpan(ref this.Reference, this.length)); @@ -436,7 +436,7 @@ internal void CopyFrom(ReadOnlySpan source) /// Whether or not the operation was successful. public bool TryCopyFrom(ReadOnlySpan source) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER int length = this.length; #elif NETSTANDARD2_1_OR_GREATER int length = this.Span.Length; @@ -460,7 +460,7 @@ public bool TryCopyFrom(ReadOnlySpan source) /// The value to assign to each element of the instance. public void Fill(T value) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER if (this.Step == 1) { MemoryMarshal.CreateSpan(ref this.Reference, this.length).Fill(value); @@ -498,7 +498,7 @@ public void Fill(T value) /// public T[] ToArray() { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER int length = this.length; #elif NETSTANDARD2_1_OR_GREATER int length = this.Span.Length; @@ -524,7 +524,7 @@ public T[] ToArray() /// public ref struct Enumerator { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER /// private readonly ref T reference; @@ -552,7 +552,7 @@ public ref struct Enumerator /// private int position; -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER /// /// Initializes a new instance of the struct. /// @@ -603,7 +603,7 @@ internal Enumerator(object? instance, IntPtr offset, int length, int step) [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool MoveNext() { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return ++this.position < this.length; #elif NETSTANDARD2_1_OR_GREATER return ++this.position < this.span.Length; @@ -618,7 +618,7 @@ public readonly ref T Current [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER ref T r0 = ref this.reference; #elif NETSTANDARD2_1_OR_GREATER ref T r0 = ref this.span.DangerousGetReference(); diff --git a/src/CommunityToolkit.HighPerformance/Enumerables/SpanEnumerable{T}.cs b/src/CommunityToolkit.HighPerformance/Enumerables/SpanEnumerable{T}.cs index dcfce51c0..d6be340a0 100644 --- a/src/CommunityToolkit.HighPerformance/Enumerables/SpanEnumerable{T}.cs +++ b/src/CommunityToolkit.HighPerformance/Enumerables/SpanEnumerable{T}.cs @@ -86,7 +86,7 @@ public readonly Item Current [EditorBrowsable(EditorBrowsableState.Never)] public readonly ref struct Item { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER /// /// The reference for the instance. /// @@ -112,7 +112,7 @@ public readonly ref struct Item [MethodImpl(MethodImplOptions.AggressiveInlining)] public Item(ref T value, int index) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref value; this.index = index; #else @@ -146,7 +146,7 @@ public ref T Value [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return ref this.reference; #elif NETSTANDARD2_1_OR_GREATER return ref MemoryMarshal.GetReference(this.span); @@ -167,7 +167,7 @@ public int Index [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return this.index; #elif NETSTANDARD2_1_OR_GREATER return this.span.Length; diff --git a/src/CommunityToolkit.HighPerformance/Extensions/NullableExtensions.cs b/src/CommunityToolkit.HighPerformance/Extensions/NullableExtensions.cs index f4a6cac3a..baa51aa8a 100644 --- a/src/CommunityToolkit.HighPerformance/Extensions/NullableExtensions.cs +++ b/src/CommunityToolkit.HighPerformance/Extensions/NullableExtensions.cs @@ -35,7 +35,7 @@ public static class NullableExtensions public static ref T DangerousGetValueOrDefaultReference(this ref T? value) where T : struct { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return ref Unsafe.AsRef(in Nullable.GetValueRefOrDefaultRef(in value)); #else return ref Unsafe.As>(ref value).Value; @@ -53,7 +53,7 @@ public static ref T DangerousGetValueOrDefaultReference(this ref T? value) public static unsafe ref T DangerousGetValueOrNullReference(ref this T? value) where T : struct { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER ref T resultRef = ref *(T*)null; // This pattern ensures that the resulting code ends up having a single return, and a single @@ -84,7 +84,7 @@ public static unsafe ref T DangerousGetValueOrNullReference(ref this T? value #endif } -#if !NET7_0_OR_GREATER +#if !NET8_0_OR_GREATER /// /// Mapping type that reflects the internal layout of the type. /// See https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Nullable.cs. diff --git a/src/CommunityToolkit.HighPerformance/Extensions/SpinLockExtensions.cs b/src/CommunityToolkit.HighPerformance/Extensions/SpinLockExtensions.cs index c9cd360d9..70fa70ad4 100644 --- a/src/CommunityToolkit.HighPerformance/Extensions/SpinLockExtensions.cs +++ b/src/CommunityToolkit.HighPerformance/Extensions/SpinLockExtensions.cs @@ -80,7 +80,7 @@ public void Dispose() } } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER /// /// Enters a specified instance and returns a wrapper to use to release the lock. /// This extension should be used though a block or statement: diff --git a/src/CommunityToolkit.HighPerformance/Extensions/StreamExtensions.cs b/src/CommunityToolkit.HighPerformance/Extensions/StreamExtensions.cs index 0cee5f4c9..c1351b5f9 100644 --- a/src/CommunityToolkit.HighPerformance/Extensions/StreamExtensions.cs +++ b/src/CommunityToolkit.HighPerformance/Extensions/StreamExtensions.cs @@ -205,7 +205,7 @@ public static void Write(this Stream stream, ReadOnlySpan buffer) public static unsafe T Read(this Stream stream) where T : unmanaged { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER T result; stream.ReadExactly(new Span(&result, sizeof(T))); @@ -299,7 +299,7 @@ public static unsafe void Write(this Stream stream, in T value) #endif } -#if !NET7_0_OR_GREATER +#if !NET8_0_OR_GREATER /// /// Throws an when fails. /// diff --git a/src/CommunityToolkit.HighPerformance/Memory/ReadOnlySpan2D{T}.Enumerator.cs b/src/CommunityToolkit.HighPerformance/Memory/ReadOnlySpan2D{T}.Enumerator.cs index 0acd16c43..0453a7927 100644 --- a/src/CommunityToolkit.HighPerformance/Memory/ReadOnlySpan2D{T}.Enumerator.cs +++ b/src/CommunityToolkit.HighPerformance/Memory/ReadOnlySpan2D{T}.Enumerator.cs @@ -2,13 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if !NET7_0_OR_GREATER +#if !NET8_0_OR_GREATER using System; #endif using System.Runtime.CompilerServices; using CommunityToolkit.HighPerformance.Enumerables; using CommunityToolkit.HighPerformance.Memory.Internals; -#if NETSTANDARD2_1_OR_GREATER && !NET7_0_OR_GREATER +#if NETSTANDARD2_1_OR_GREATER && !NET8_0_OR_GREATER using System.Runtime.InteropServices; #elif NETSTANDARD2_0 using RuntimeHelpers = CommunityToolkit.HighPerformance.Helpers.Internals.RuntimeHelpers; @@ -86,7 +86,7 @@ public ReadOnlyRefEnumerable GetColumn(int column) /// public ref struct Enumerator { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER /// /// The reference for the instance. /// @@ -145,7 +145,7 @@ public ref struct Enumerator /// The target instance to enumerate. internal Enumerator(ReadOnlySpan2D span) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref span.reference; this.height = span.height; #elif NETSTANDARD2_1_OR_GREATER @@ -182,7 +182,7 @@ public bool MoveNext() // another row available: wrap to a new line and continue. this.x = 0; -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return ++this.y < this.height; #elif NETSTANDARD2_1_OR_GREATER return ++this.y < this.span.Length; @@ -199,7 +199,7 @@ public readonly ref readonly T Current [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER ref T r0 = ref Unsafe.AsRef(in this.reference); #elif NETSTANDARD2_1_OR_GREATER ref T r0 = ref MemoryMarshal.GetReference(this.span); diff --git a/src/CommunityToolkit.HighPerformance/Memory/ReadOnlySpan2D{T}.cs b/src/CommunityToolkit.HighPerformance/Memory/ReadOnlySpan2D{T}.cs index bbdbe6a1c..a56475ed4 100644 --- a/src/CommunityToolkit.HighPerformance/Memory/ReadOnlySpan2D{T}.cs +++ b/src/CommunityToolkit.HighPerformance/Memory/ReadOnlySpan2D{T}.cs @@ -28,7 +28,7 @@ namespace CommunityToolkit.HighPerformance; [DebuggerDisplay("{ToString(),raw}")] public readonly ref partial struct ReadOnlySpan2D { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER /// /// The reference for the instance. /// @@ -81,7 +81,7 @@ public readonly ref partial struct ReadOnlySpan2D [MethodImpl(MethodImplOptions.AggressiveInlining)] internal ReadOnlySpan2D(in T value, int height, int width, int pitch) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref value; this.height = height; #else @@ -124,7 +124,7 @@ public unsafe ReadOnlySpan2D(void* pointer, int height, int width, int pitch) OverflowHelper.EnsureIsInNativeIntRange(height, width, pitch); -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref Unsafe.AsRef(pointer); this.height = height; #elif NETSTANDARD2_1_OR_GREATER @@ -224,7 +224,7 @@ public ReadOnlySpan2D(T[] array, int offset, int height, int width, int pitch) ThrowHelper.ThrowArgumentException(); } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref array.DangerousGetReferenceAt(offset); this.height = height; #elif NETSTANDARD2_1_OR_GREATER @@ -251,7 +251,7 @@ public ReadOnlySpan2D(T[,]? array) return; } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref array.DangerousGetReference(); this.height = array.GetLength(0); #elif NETSTANDARD2_1_OR_GREATER @@ -313,7 +313,7 @@ public ReadOnlySpan2D(T[,]? array, int row, int column, int height, int width) ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref array.DangerousGetReferenceAt(row, column); this.height = height; #elif NETSTANDARD2_1_OR_GREATER @@ -340,7 +340,7 @@ public ReadOnlySpan2D(T[,,] array, int depth) ThrowHelper.ThrowArgumentOutOfRangeExceptionForDepth(); } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref array.DangerousGetReferenceAt(depth, 0, 0); this.height = array.GetLength(1); #elif NETSTANDARD2_1_OR_GREATER @@ -393,7 +393,7 @@ public ReadOnlySpan2D(T[,,] array, int depth, int row, int column, int height, i ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref array.DangerousGetReferenceAt(depth, row, column); this.height = height; #elif NETSTANDARD2_1_OR_GREATER @@ -474,7 +474,7 @@ internal ReadOnlySpan2D(ReadOnlySpan span, int offset, int height, int width, ThrowHelper.ThrowArgumentException(); } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref span.DangerousGetReferenceAt(offset); this.height = height; #else @@ -547,7 +547,7 @@ public int Height [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return this.height; #elif NETSTANDARD2_1_OR_GREATER return this.span.Length; @@ -786,7 +786,7 @@ public unsafe ref readonly T GetPinnableReference() if (Length != 0) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER r0 = ref this.reference; #elif NETSTANDARD2_1_OR_GREATER r0 = ref MemoryMarshal.GetReference(this.span); @@ -805,7 +805,7 @@ public unsafe ref readonly T GetPinnableReference() [MethodImpl(MethodImplOptions.AggressiveInlining)] public ref T DangerousGetReference() { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return ref Unsafe.AsRef(in this.reference); #elif NETSTANDARD2_1_OR_GREATER return ref MemoryMarshal.GetReference(this.span); @@ -823,7 +823,7 @@ public ref T DangerousGetReference() [MethodImpl(MethodImplOptions.AggressiveInlining)] public ref T DangerousGetReferenceAt(int i, int j) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER ref T r0 = ref Unsafe.AsRef(in this.reference); #elif NETSTANDARD2_1_OR_GREATER ref T r0 = ref MemoryMarshal.GetReference(this.span); @@ -873,7 +873,7 @@ public unsafe ReadOnlySpan2D Slice(int row, int column, int height, int width nint shift = ((nint)(uint)this.stride * (nint)(uint)row) + (nint)(uint)column; int pitch = this.stride - width; -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER ref T r0 = ref Unsafe.Add(ref Unsafe.AsRef(in this.reference), shift); return new(in r0, height, width, pitch); @@ -919,7 +919,7 @@ public bool TryGetSpan(out ReadOnlySpan span) if (this.stride == this.width && Length <= int.MaxValue) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER span = MemoryMarshal.CreateSpan(ref Unsafe.AsRef(in this.reference), (int)Length); return true; @@ -1034,7 +1034,7 @@ public override string ToString() public static bool operator ==(ReadOnlySpan2D left, ReadOnlySpan2D right) { return -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER Unsafe.AreSame(ref Unsafe.AsRef(in left.reference), ref Unsafe.AsRef(in right.reference)) && left.height == right.height && #elif NETSTANDARD2_1_OR_GREATER diff --git a/src/CommunityToolkit.HighPerformance/Memory/Span2D{T}.Enumerator.cs b/src/CommunityToolkit.HighPerformance/Memory/Span2D{T}.Enumerator.cs index 1fda07c9f..0d4e02d84 100644 --- a/src/CommunityToolkit.HighPerformance/Memory/Span2D{T}.Enumerator.cs +++ b/src/CommunityToolkit.HighPerformance/Memory/Span2D{T}.Enumerator.cs @@ -2,13 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if !NET7_0_OR_GREATER +#if !NET8_0_OR_GREATER using System; #endif using System.Runtime.CompilerServices; using CommunityToolkit.HighPerformance.Enumerables; using CommunityToolkit.HighPerformance.Memory.Internals; -#if NETSTANDARD2_1_OR_GREATER && !NET7_0_OR_GREATER +#if NETSTANDARD2_1_OR_GREATER && !NET8_0_OR_GREATER using System.Runtime.InteropServices; #elif NETSTANDARD2_0 using RuntimeHelpers = CommunityToolkit.HighPerformance.Helpers.Internals.RuntimeHelpers; @@ -86,7 +86,7 @@ public RefEnumerable GetColumn(int column) /// public ref struct Enumerator { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER /// /// The reference for the instance. /// @@ -145,7 +145,7 @@ public ref struct Enumerator /// The target instance to enumerate. internal Enumerator(Span2D span) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref span.reference; this.height = span.height; #elif NETSTANDARD2_1_OR_GREATER @@ -182,7 +182,7 @@ public bool MoveNext() // another row available: wrap to a new line and continue. this.x = 0; -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return ++this.y < this.height; #elif NETSTANDARD2_1_OR_GREATER return ++this.y < this.span.Length; @@ -199,7 +199,7 @@ public readonly ref T Current [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER ref T r0 = ref this.reference; #elif NETSTANDARD2_1_OR_GREATER ref T r0 = ref MemoryMarshal.GetReference(this.span); diff --git a/src/CommunityToolkit.HighPerformance/Memory/Span2D{T}.cs b/src/CommunityToolkit.HighPerformance/Memory/Span2D{T}.cs index 992269292..f48f35d11 100644 --- a/src/CommunityToolkit.HighPerformance/Memory/Span2D{T}.cs +++ b/src/CommunityToolkit.HighPerformance/Memory/Span2D{T}.cs @@ -56,7 +56,7 @@ public readonly ref partial struct Span2D // discontiguous row, so that any arbitrary memory locations // can be used to internally represent a 2D span. This gives // users much more flexibility when creating spans from data. -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER /// /// The reference for the instance. /// @@ -117,7 +117,7 @@ public readonly ref partial struct Span2D [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Span2D(ref T value, int height, int width, int pitch) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref value; this.height = height; #else @@ -160,7 +160,7 @@ public unsafe Span2D(void* pointer, int height, int width, int pitch) OverflowHelper.EnsureIsInNativeIntRange(height, width, pitch); -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref Unsafe.AsRef(pointer); this.height = height; #elif NETSTANDARD2_1_OR_GREATER @@ -264,7 +264,7 @@ public Span2D(T[] array, int offset, int height, int width, int pitch) ThrowHelper.ThrowArgumentException(); } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref array.DangerousGetReferenceAt(offset); this.height = height; #elif NETSTANDARD2_1_OR_GREATER @@ -299,7 +299,7 @@ public Span2D(T[,]? array) ThrowHelper.ThrowArrayTypeMismatchException(); } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref array.DangerousGetReference(); this.height = array.GetLength(0); #elif NETSTANDARD2_1_OR_GREATER @@ -369,7 +369,7 @@ public Span2D(T[,]? array, int row, int column, int height, int width) ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref array.DangerousGetReferenceAt(row, column); this.height = height; #elif NETSTANDARD2_1_OR_GREATER @@ -404,7 +404,7 @@ public Span2D(T[,,] array, int depth) ThrowHelper.ThrowArgumentOutOfRangeExceptionForDepth(); } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref array.DangerousGetReferenceAt(depth, 0, 0); this.height = array.GetLength(1); #elif NETSTANDARD2_1_OR_GREATER @@ -465,7 +465,7 @@ public Span2D(T[,,] array, int depth, int row, int column, int height, int width ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref array.DangerousGetReferenceAt(depth, row, column); this.height = height; #elif NETSTANDARD2_1_OR_GREATER @@ -546,7 +546,7 @@ internal Span2D(Span span, int offset, int height, int width, int pitch) ThrowHelper.ThrowArgumentException(); } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER this.reference = ref span.DangerousGetReferenceAt(offset); this.height = height; #else @@ -619,7 +619,7 @@ public int Height [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return this.height; #elif NETSTANDARD2_1_OR_GREATER return this.span.Length; @@ -943,7 +943,7 @@ public unsafe ref T GetPinnableReference() if (Length != 0) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER r0 = ref this.reference; #elif NETSTANDARD2_1_OR_GREATER r0 = ref MemoryMarshal.GetReference(this.span); @@ -962,7 +962,7 @@ public unsafe ref T GetPinnableReference() [MethodImpl(MethodImplOptions.AggressiveInlining)] public ref T DangerousGetReference() { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER return ref this.reference; #elif NETSTANDARD2_1_OR_GREATER return ref MemoryMarshal.GetReference(this.span); @@ -980,7 +980,7 @@ public ref T DangerousGetReference() [MethodImpl(MethodImplOptions.AggressiveInlining)] public ref T DangerousGetReferenceAt(int i, int j) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER ref T r0 = ref this.reference; #elif NETSTANDARD2_1_OR_GREATER ref T r0 = ref MemoryMarshal.GetReference(this.span); @@ -1052,7 +1052,7 @@ public unsafe Span2D Slice(int row, int column, int height, int width) nint shift = ((nint)(uint)this.Stride * (nint)(uint)row) + (nint)(uint)column; int pitch = this.Stride - width; -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER ref T r0 = ref Unsafe.Add(ref this.reference, shift); return new(ref r0, height, width, pitch); @@ -1098,7 +1098,7 @@ public bool TryGetSpan(out Span span) if (this.Stride == this.width && Length <= int.MaxValue) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER span = MemoryMarshal.CreateSpan(ref this.reference, (int)Length); return true; @@ -1213,7 +1213,7 @@ public override string ToString() public static bool operator ==(Span2D left, Span2D right) { return -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER Unsafe.AreSame(ref left.reference, ref right.reference) && left.height == right.height && #elif NETSTANDARD2_1_OR_GREATER diff --git a/src/CommunityToolkit.HighPerformance/NullableReadOnlyRef{T}.cs b/src/CommunityToolkit.HighPerformance/NullableReadOnlyRef{T}.cs index 298dc0f70..4bfabc88e 100644 --- a/src/CommunityToolkit.HighPerformance/NullableReadOnlyRef{T}.cs +++ b/src/CommunityToolkit.HighPerformance/NullableReadOnlyRef{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 NET7_0_OR_GREATER +#if NET8_0_OR_GREATER using System; using System.Runtime.CompilerServices; diff --git a/src/CommunityToolkit.HighPerformance/NullableRef{T}.cs b/src/CommunityToolkit.HighPerformance/NullableRef{T}.cs index 9e31c0bbf..c951d7d15 100644 --- a/src/CommunityToolkit.HighPerformance/NullableRef{T}.cs +++ b/src/CommunityToolkit.HighPerformance/NullableRef{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 NET7_0_OR_GREATER +#if NET8_0_OR_GREATER using System; using System.Runtime.CompilerServices; diff --git a/src/CommunityToolkit.HighPerformance/ReadOnlyRef{T}.cs b/src/CommunityToolkit.HighPerformance/ReadOnlyRef{T}.cs index 31ac75b33..a61de6d55 100644 --- a/src/CommunityToolkit.HighPerformance/ReadOnlyRef{T}.cs +++ b/src/CommunityToolkit.HighPerformance/ReadOnlyRef{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 NET7_0_OR_GREATER +#if NET8_0_OR_GREATER using System.Runtime.CompilerServices; diff --git a/src/CommunityToolkit.HighPerformance/Ref{T}.cs b/src/CommunityToolkit.HighPerformance/Ref{T}.cs index 59ac62469..c1b62aa56 100644 --- a/src/CommunityToolkit.HighPerformance/Ref{T}.cs +++ b/src/CommunityToolkit.HighPerformance/Ref{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 NET7_0_OR_GREATER +#if NET8_0_OR_GREATER using System.Runtime.CompilerServices;