diff --git a/src/Common/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs b/src/Common/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs index fdee6012a128..f8fb7b6baf2e 100644 --- a/src/Common/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs +++ b/src/Common/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs @@ -165,18 +165,16 @@ public bool IsEmpty /// /// Thrown when index less than 0 or index greater than or equal to Length /// -#if PROJECTN + public ref readonly T this[int index] { +#if PROJECTN [BoundsChecking] get { return ref Unsafe.Add(ref _pointer.Value, index); } - } #else - public T this[int index] - { [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] @@ -184,10 +182,10 @@ public T this[int index] { if ((uint)index >= (uint)_length) ThrowHelper.ThrowIndexOutOfRangeException(); - return Unsafe.Add(ref _pointer.Value, index); + return ref Unsafe.Add(ref _pointer.Value, index); } - } #endif + } /// /// Copies the contents of this read-only span into destination span. If the source