Skip to content

Commit 986fbae

Browse files
authored
Merge pull request #5 from rameel/fix-arrayview
Fix an issue in `ArrayView<T>` incorrectly returned a mutable reference
2 parents 3cad21e + 39b5a77 commit 986fbae

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Ramstack.Structures/Collections/ArrayView`1.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace Ramstack.Collections;
3737
public bool IsDefault => _array is null;
3838

3939
/// <inheritdoc cref="IReadOnlyList{T}.this"/>
40-
public ref T this[int index]
40+
public ref readonly T this[int index]
4141
{
4242
[MethodImpl(MethodImplOptions.AggressiveInlining)]
4343
get
@@ -202,7 +202,7 @@ public ReadOnlyMemory<T> AsMemory() =>
202202
/// A reference to the element of the <see cref="ArrayView{T}"/> at index zero.
203203
/// </returns>
204204
[MethodImpl(MethodImplOptions.AggressiveInlining)]
205-
public ref T GetPinnableReference()
205+
public ref readonly T GetPinnableReference()
206206
{
207207
// To match the behavior of ReadOnlySpan<T>
208208

0 commit comments

Comments
 (0)