Skip to content

Commit bc1b91d

Browse files
Fix ArrayExtensions AsSpan() and AsMemory() helpers
These were incorrectly defined to return ReadOnlySpan<T> and ReadOnlyMemory<T> but _should_ return Span<T> and Memory<T> to match the equivalent BCL methods.
1 parent e0d6317 commit bc1b91d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared/ArrayExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal static class ArrayExtensions
3131
/// <exception cref="ArrayTypeMismatchException">
3232
/// <paramref name="array"/> is covariant, and the array's type is not exactly <typeparamref name="T"/>[].
3333
/// </exception>
34-
public static ReadOnlySpan<T> AsSpan<T>(this T[]? array, Index startIndex)
34+
public static Span<T> AsSpan<T>(this T[]? array, Index startIndex)
3535
{
3636
#if NET
3737
return MemoryExtensions.AsSpan(array, startIndex);
@@ -74,7 +74,7 @@ public static ReadOnlySpan<T> AsSpan<T>(this T[]? array, Index startIndex)
7474
/// <exception cref="ArrayTypeMismatchException">
7575
/// <paramref name="array"/> is covariant, and the array's type is not exactly <typeparamref name="T"/>[].
7676
/// </exception>
77-
public static ReadOnlySpan<T> AsSpan<T>(this T[]? array, Range range)
77+
public static Span<T> AsSpan<T>(this T[]? array, Range range)
7878
{
7979
#if NET
8080
return MemoryExtensions.AsSpan(array, range);
@@ -116,7 +116,7 @@ public static ReadOnlySpan<T> AsSpan<T>(this T[]? array, Range range)
116116
/// <exception cref="ArrayTypeMismatchException">
117117
/// <paramref name="array"/> is covariant, and the array's type is not exactly <typeparamref name="T"/>[].
118118
/// </exception>
119-
public static ReadOnlyMemory<T> AsMemory<T>(this T[]? array, Index startIndex)
119+
public static Memory<T> AsMemory<T>(this T[]? array, Index startIndex)
120120
{
121121
#if NET
122122
return MemoryExtensions.AsMemory(array, startIndex);
@@ -160,7 +160,7 @@ public static ReadOnlyMemory<T> AsMemory<T>(this T[]? array, Index startIndex)
160160
/// <exception cref="ArrayTypeMismatchException">
161161
/// <paramref name="array"/> is covariant, and the array's type is not exactly <typeparamref name="T"/>[].
162162
/// </exception>
163-
public static ReadOnlyMemory<T> AsMemory<T>(this T[]? array, Range range)
163+
public static Memory<T> AsMemory<T>(this T[]? array, Range range)
164164
{
165165
#if NET
166166
return MemoryExtensions.AsMemory(array, range);

0 commit comments

Comments
 (0)