Skip to content

Commit 7014bff

Browse files
committed
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.
1 parent bfad004 commit 7014bff

16 files changed

+98
-98
lines changed

src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
55
</PropertyGroup>
66

77
<PropertyGroup>

src/CommunityToolkit.HighPerformance/Enumerables/ReadOnlyRefEnumerable{T}.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace CommunityToolkit.HighPerformance.Enumerables;
2121
/// <typeparam name="T">The type of items to enumerate.</typeparam>
2222
public readonly ref struct ReadOnlyRefEnumerable<T>
2323
{
24-
#if NET7_0_OR_GREATER
24+
#if NET8_0_OR_GREATER
2525
/// <summary>
2626
/// The <typeparamref name="T"/> reference for the <see cref="ReadOnlyRefEnumerable{T}"/> instance.
2727
/// </summary>
@@ -61,7 +61,7 @@ public readonly ref struct ReadOnlyRefEnumerable<T>
6161
private readonly int step;
6262

6363
#if NETSTANDARD2_1_OR_GREATER
64-
#if !NET7_0_OR_GREATER
64+
#if !NET8_0_OR_GREATER
6565
/// <summary>
6666
/// Initializes a new instance of the <see cref="ReadOnlyRefEnumerable{T}"/> struct.
6767
/// </summary>
@@ -70,7 +70,7 @@ public readonly ref struct ReadOnlyRefEnumerable<T>
7070
[MethodImpl(MethodImplOptions.AggressiveInlining)]
7171
private ReadOnlyRefEnumerable(ReadOnlySpan<T> span, int step)
7272
{
73-
#if NET7_0_OR_GREATER
73+
#if NET8_0_OR_GREATER
7474
this.reference = ref MemoryMarshal.GetReference(span);
7575
this.length = span.Length;
7676
#else
@@ -89,7 +89,7 @@ private ReadOnlyRefEnumerable(ReadOnlySpan<T> span, int step)
8989
[MethodImpl(MethodImplOptions.AggressiveInlining)]
9090
internal ReadOnlyRefEnumerable(in T reference, int length, int step)
9191
{
92-
#if NET7_0_OR_GREATER
92+
#if NET8_0_OR_GREATER
9393
this.reference = ref reference;
9494
this.length = length;
9595
this.step = step;
@@ -147,7 +147,7 @@ internal ReadOnlyRefEnumerable(object? instance, IntPtr offset, int length, int
147147
public int Length
148148
{
149149
[MethodImpl(MethodImplOptions.AggressiveInlining)]
150-
#if NET7_0_OR_GREATER
150+
#if NET8_0_OR_GREATER
151151
get => this.length;
152152
#elif NETSTANDARD2_1_OR_GREATER
153153
get => this.span.Length;
@@ -174,7 +174,7 @@ public ref readonly T this[int index]
174174
ThrowHelper.ThrowIndexOutOfRangeException();
175175
}
176176

177-
#if NET7_0_OR_GREATER
177+
#if NET8_0_OR_GREATER
178178
ref T r0 = ref Unsafe.AsRef(in this.reference);
179179
#elif NETSTANDARD2_1_OR_GREATER
180180
ref T r0 = ref MemoryMarshal.GetReference(this.span);
@@ -208,7 +208,7 @@ public ref readonly T this[Index index]
208208
[MethodImpl(MethodImplOptions.AggressiveInlining)]
209209
public Enumerator GetEnumerator()
210210
{
211-
#if NET7_0_OR_GREATER
211+
#if NET8_0_OR_GREATER
212212
return new(in this.reference, this.length, this.step);
213213
#elif NETSTANDARD2_1_OR_GREATER
214214
return new(this.span, this.step);
@@ -226,7 +226,7 @@ public Enumerator GetEnumerator()
226226
/// </exception>
227227
public void CopyTo(RefEnumerable<T> destination)
228228
{
229-
#if NET7_0_OR_GREATER
229+
#if NET8_0_OR_GREATER
230230
if (this.step == 1)
231231
{
232232
destination.CopyFrom(MemoryMarshal.CreateReadOnlySpan(ref Unsafe.AsRef(in this.reference), this.length));
@@ -286,7 +286,7 @@ public void CopyTo(RefEnumerable<T> destination)
286286
/// <returns>Whether or not the operation was successful.</returns>
287287
public bool TryCopyTo(RefEnumerable<T> destination)
288288
{
289-
#if NET7_0_OR_GREATER
289+
#if NET8_0_OR_GREATER
290290
int sourceLength = this.length;
291291
int destinationLength = destination.Length;
292292
#elif NETSTANDARD2_1_OR_GREATER
@@ -316,7 +316,7 @@ public bool TryCopyTo(RefEnumerable<T> destination)
316316
/// </exception>
317317
public void CopyTo(Span<T> destination)
318318
{
319-
#if NET7_0_OR_GREATER
319+
#if NET8_0_OR_GREATER
320320
if (this.step == 1)
321321
{
322322
MemoryMarshal.CreateReadOnlySpan(ref Unsafe.AsRef(in this.reference), this.length).CopyTo(destination);
@@ -357,7 +357,7 @@ public void CopyTo(Span<T> destination)
357357
/// <returns>Whether or not the operation was successful.</returns>
358358
public bool TryCopyTo(Span<T> destination)
359359
{
360-
#if NET7_0_OR_GREATER
360+
#if NET8_0_OR_GREATER
361361
int length = this.length;
362362
#elif NETSTANDARD2_1_OR_GREATER
363363
int length = this.span.Length;
@@ -378,7 +378,7 @@ public bool TryCopyTo(Span<T> destination)
378378
/// <inheritdoc cref="RefEnumerable{T}.ToArray"/>
379379
public T[] ToArray()
380380
{
381-
#if NET7_0_OR_GREATER
381+
#if NET8_0_OR_GREATER
382382
int length = this.length;
383383
#elif NETSTANDARD2_1_OR_GREATER
384384
int length = this.span.Length;
@@ -406,7 +406,7 @@ public T[] ToArray()
406406
[MethodImpl(MethodImplOptions.AggressiveInlining)]
407407
public static implicit operator ReadOnlyRefEnumerable<T>(RefEnumerable<T> enumerable)
408408
{
409-
#if NET7_0_OR_GREATER
409+
#if NET8_0_OR_GREATER
410410
return new(in enumerable.Reference, enumerable.Length, enumerable.Step);
411411
#elif NETSTANDARD2_1_OR_GREATER
412412
return new(enumerable.Span, enumerable.Step);
@@ -420,7 +420,7 @@ public static implicit operator ReadOnlyRefEnumerable<T>(RefEnumerable<T> enumer
420420
/// </summary>
421421
public ref struct Enumerator
422422
{
423-
#if NET7_0_OR_GREATER
423+
#if NET8_0_OR_GREATER
424424
/// <inheritdoc cref="ReadOnlyRefEnumerable{T}.reference"/>
425425
private readonly ref readonly T reference;
426426

@@ -448,7 +448,7 @@ public ref struct Enumerator
448448
/// </summary>
449449
private int position;
450450

451-
#if NET7_0_OR_GREATER
451+
#if NET8_0_OR_GREATER
452452
/// <summary>
453453
/// Initializes a new instance of the <see cref="Enumerator"/> struct.
454454
/// </summary>
@@ -499,7 +499,7 @@ internal Enumerator(object? instance, IntPtr offset, int length, int step)
499499
[MethodImpl(MethodImplOptions.AggressiveInlining)]
500500
public bool MoveNext()
501501
{
502-
#if NET7_0_OR_GREATER
502+
#if NET8_0_OR_GREATER
503503
return ++this.position < this.length;
504504
#elif NETSTANDARD2_1_OR_GREATER
505505
return ++this.position < this.span.Length;
@@ -514,7 +514,7 @@ public readonly ref readonly T Current
514514
[MethodImpl(MethodImplOptions.AggressiveInlining)]
515515
get
516516
{
517-
#if NET7_0_OR_GREATER
517+
#if NET8_0_OR_GREATER
518518
ref T r0 = ref Unsafe.AsRef(in this.reference);
519519
#elif NETSTANDARD2_1_OR_GREATER
520520
ref T r0 = ref this.span.DangerousGetReference();

src/CommunityToolkit.HighPerformance/Enumerables/ReadOnlySpanEnumerable{T}.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public readonly Item Current
8181
[EditorBrowsable(EditorBrowsableState.Never)]
8282
public readonly ref struct Item
8383
{
84-
#if NET7_0_OR_GREATER
84+
#if NET8_0_OR_GREATER
8585
/// <summary>
8686
/// The <typeparamref name="T"/> reference for the <see cref="Item"/> instance.
8787
/// </summary>
@@ -107,7 +107,7 @@ public readonly ref struct Item
107107
[MethodImpl(MethodImplOptions.AggressiveInlining)]
108108
public Item(ref T value, int index)
109109
{
110-
#if NET7_0_OR_GREATER
110+
#if NET8_0_OR_GREATER
111111
this.reference = ref value;
112112
this.index = index;
113113
#else
@@ -141,7 +141,7 @@ public ref readonly T Value
141141
[MethodImpl(MethodImplOptions.AggressiveInlining)]
142142
get
143143
{
144-
#if NET7_0_OR_GREATER
144+
#if NET8_0_OR_GREATER
145145
return ref this.reference;
146146
#elif NETSTANDARD2_1_OR_GREATER
147147
return ref MemoryMarshal.GetReference(this.span);
@@ -162,7 +162,7 @@ public int Index
162162
[MethodImpl(MethodImplOptions.AggressiveInlining)]
163163
get
164164
{
165-
#if NET7_0_OR_GREATER
165+
#if NET8_0_OR_GREATER
166166
return this.index;
167167
#elif NETSTANDARD2_1_OR_GREATER
168168
return this.span.Length;

src/CommunityToolkit.HighPerformance/Enumerables/RefEnumerable{T}.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace CommunityToolkit.HighPerformance.Enumerables;
2121
/// <typeparam name="T">The type of items to enumerate.</typeparam>
2222
public readonly ref struct RefEnumerable<T>
2323
{
24-
#if NET7_0_OR_GREATER
24+
#if NET8_0_OR_GREATER
2525
/// <summary>
2626
/// The <typeparamref name="T"/> reference for the <see cref="RefEnumerable{T}"/> instance.
2727
/// </summary>
@@ -65,7 +65,7 @@ public readonly ref struct RefEnumerable<T>
6565
[MethodImpl(MethodImplOptions.AggressiveInlining)]
6666
internal RefEnumerable(ref T reference, int length, int step)
6767
{
68-
#if NET7_0_OR_GREATER
68+
#if NET8_0_OR_GREATER
6969
this.Reference = ref reference;
7070
this.length = length;
7171
#else
@@ -123,7 +123,7 @@ internal RefEnumerable(object? instance, IntPtr offset, int length, int step)
123123
public int Length
124124
{
125125
[MethodImpl(MethodImplOptions.AggressiveInlining)]
126-
#if NET7_0_OR_GREATER
126+
#if NET8_0_OR_GREATER
127127
get => this.length;
128128
#elif NETSTANDARD2_1_OR_GREATER
129129
get => this.Span.Length;
@@ -150,7 +150,7 @@ public ref T this[int index]
150150
ThrowHelper.ThrowIndexOutOfRangeException();
151151
}
152152

153-
#if NET7_0_OR_GREATER
153+
#if NET8_0_OR_GREATER
154154
ref T r0 = ref this.Reference;
155155
#elif NETSTANDARD2_1_OR_GREATER
156156
ref T r0 = ref MemoryMarshal.GetReference(this.Span);
@@ -184,7 +184,7 @@ public ref T this[Index index]
184184
[MethodImpl(MethodImplOptions.AggressiveInlining)]
185185
public Enumerator GetEnumerator()
186186
{
187-
#if NET7_0_OR_GREATER
187+
#if NET8_0_OR_GREATER
188188
return new(ref this.Reference, this.length, this.Step);
189189
#elif NETSTANDARD2_1_OR_GREATER
190190
return new(this.Span, this.Step);
@@ -198,7 +198,7 @@ public Enumerator GetEnumerator()
198198
/// </summary>
199199
public void Clear()
200200
{
201-
#if NET7_0_OR_GREATER
201+
#if NET8_0_OR_GREATER
202202
// Fast path for contiguous items
203203
if (this.Step == 1)
204204
{
@@ -236,7 +236,7 @@ public void Clear()
236236
/// </exception>
237237
public void CopyTo(RefEnumerable<T> destination)
238238
{
239-
#if NET7_0_OR_GREATER
239+
#if NET8_0_OR_GREATER
240240
if (this.Step == 1)
241241
{
242242
destination.CopyFrom(MemoryMarshal.CreateReadOnlySpan(ref this.Reference, this.length));
@@ -296,7 +296,7 @@ public void CopyTo(RefEnumerable<T> destination)
296296
/// <returns>Whether or not the operation was successful.</returns>
297297
public bool TryCopyTo(RefEnumerable<T> destination)
298298
{
299-
#if NET7_0_OR_GREATER
299+
#if NET8_0_OR_GREATER
300300
int sourceLength = this.length;
301301
int destinationLength = destination.length;
302302
#elif NETSTANDARD2_1_OR_GREATER
@@ -326,7 +326,7 @@ public bool TryCopyTo(RefEnumerable<T> destination)
326326
/// </exception>
327327
public void CopyTo(Span<T> destination)
328328
{
329-
#if NET7_0_OR_GREATER
329+
#if NET8_0_OR_GREATER
330330
if (this.Step == 1)
331331
{
332332
MemoryMarshal.CreateReadOnlySpan(ref this.Reference, this.length).CopyTo(destination);
@@ -367,7 +367,7 @@ public void CopyTo(Span<T> destination)
367367
/// <returns>Whether or not the operation was successful.</returns>
368368
public bool TryCopyTo(Span<T> destination)
369369
{
370-
#if NET7_0_OR_GREATER
370+
#if NET8_0_OR_GREATER
371371
int length = this.length;
372372
#elif NETSTANDARD2_1_OR_GREATER
373373
int length = this.Span.Length;
@@ -394,7 +394,7 @@ public bool TryCopyTo(Span<T> destination)
394394
/// </exception>
395395
internal void CopyFrom(ReadOnlySpan<T> source)
396396
{
397-
#if NET7_0_OR_GREATER
397+
#if NET8_0_OR_GREATER
398398
if (this.Step == 1)
399399
{
400400
source.CopyTo(MemoryMarshal.CreateSpan(ref this.Reference, this.length));
@@ -436,7 +436,7 @@ internal void CopyFrom(ReadOnlySpan<T> source)
436436
/// <returns>Whether or not the operation was successful.</returns>
437437
public bool TryCopyFrom(ReadOnlySpan<T> source)
438438
{
439-
#if NET7_0_OR_GREATER
439+
#if NET8_0_OR_GREATER
440440
int length = this.length;
441441
#elif NETSTANDARD2_1_OR_GREATER
442442
int length = this.Span.Length;
@@ -460,7 +460,7 @@ public bool TryCopyFrom(ReadOnlySpan<T> source)
460460
/// <param name="value">The value to assign to each element of the <see cref="RefEnumerable{T}"/> instance.</param>
461461
public void Fill(T value)
462462
{
463-
#if NET7_0_OR_GREATER
463+
#if NET8_0_OR_GREATER
464464
if (this.Step == 1)
465465
{
466466
MemoryMarshal.CreateSpan(ref this.Reference, this.length).Fill(value);
@@ -498,7 +498,7 @@ public void Fill(T value)
498498
/// </remarks>
499499
public T[] ToArray()
500500
{
501-
#if NET7_0_OR_GREATER
501+
#if NET8_0_OR_GREATER
502502
int length = this.length;
503503
#elif NETSTANDARD2_1_OR_GREATER
504504
int length = this.Span.Length;
@@ -524,7 +524,7 @@ public T[] ToArray()
524524
/// </summary>
525525
public ref struct Enumerator
526526
{
527-
#if NET7_0_OR_GREATER
527+
#if NET8_0_OR_GREATER
528528
/// <inheritdoc cref="RefEnumerable{T}.Reference"/>
529529
private readonly ref T reference;
530530

@@ -552,7 +552,7 @@ public ref struct Enumerator
552552
/// </summary>
553553
private int position;
554554

555-
#if NET7_0_OR_GREATER
555+
#if NET8_0_OR_GREATER
556556
/// <summary>
557557
/// Initializes a new instance of the <see cref="Enumerator"/> struct.
558558
/// </summary>
@@ -603,7 +603,7 @@ internal Enumerator(object? instance, IntPtr offset, int length, int step)
603603
[MethodImpl(MethodImplOptions.AggressiveInlining)]
604604
public bool MoveNext()
605605
{
606-
#if NET7_0_OR_GREATER
606+
#if NET8_0_OR_GREATER
607607
return ++this.position < this.length;
608608
#elif NETSTANDARD2_1_OR_GREATER
609609
return ++this.position < this.span.Length;
@@ -618,7 +618,7 @@ public readonly ref T Current
618618
[MethodImpl(MethodImplOptions.AggressiveInlining)]
619619
get
620620
{
621-
#if NET7_0_OR_GREATER
621+
#if NET8_0_OR_GREATER
622622
ref T r0 = ref this.reference;
623623
#elif NETSTANDARD2_1_OR_GREATER
624624
ref T r0 = ref this.span.DangerousGetReference();

src/CommunityToolkit.HighPerformance/Enumerables/SpanEnumerable{T}.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public readonly Item Current
8686
[EditorBrowsable(EditorBrowsableState.Never)]
8787
public readonly ref struct Item
8888
{
89-
#if NET7_0_OR_GREATER
89+
#if NET8_0_OR_GREATER
9090
/// <summary>
9191
/// The <typeparamref name="T"/> reference for the <see cref="Item"/> instance.
9292
/// </summary>
@@ -112,7 +112,7 @@ public readonly ref struct Item
112112
[MethodImpl(MethodImplOptions.AggressiveInlining)]
113113
public Item(ref T value, int index)
114114
{
115-
#if NET7_0_OR_GREATER
115+
#if NET8_0_OR_GREATER
116116
this.reference = ref value;
117117
this.index = index;
118118
#else
@@ -146,7 +146,7 @@ public ref T Value
146146
[MethodImpl(MethodImplOptions.AggressiveInlining)]
147147
get
148148
{
149-
#if NET7_0_OR_GREATER
149+
#if NET8_0_OR_GREATER
150150
return ref this.reference;
151151
#elif NETSTANDARD2_1_OR_GREATER
152152
return ref MemoryMarshal.GetReference(this.span);
@@ -167,7 +167,7 @@ public int Index
167167
[MethodImpl(MethodImplOptions.AggressiveInlining)]
168168
get
169169
{
170-
#if NET7_0_OR_GREATER
170+
#if NET8_0_OR_GREATER
171171
return this.index;
172172
#elif NETSTANDARD2_1_OR_GREATER
173173
return this.span.Length;

0 commit comments

Comments
 (0)