File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -780,14 +780,14 @@ public bool TryCopyTo(Span2D<T> destination)
780
780
/// <returns>A reference to the 0th element, or a <see langword="null"/> reference.</returns>
781
781
[ MethodImpl( MethodImplOptions. AggressiveInlining) ]
782
782
[ EditorBrowsable( EditorBrowsableState. Never) ]
783
- public unsafe ref T GetPinnableReference( )
783
+ public unsafe ref readonly T GetPinnableReference( )
784
784
{
785
- ref T r0 = ref Unsafe. AsRef< T> ( null ) ;
785
+ ref readonly T r0 = ref Unsafe. AsRef< T> ( null ) ;
786
786
787
787
if ( Length != 0 )
788
788
{
789
789
#if NET7_0_OR_GREATER
790
- r0 = ref Unsafe . AsRef ( in this . reference) ;
790
+ r0 = ref this . reference;
791
791
#elif NETSTANDARD2_1_OR_GREATER
792
792
r0 = ref MemoryMarshal. GetReference( this . span) ;
793
793
#else
Original file line number Diff line number Diff line change @@ -351,7 +351,7 @@ public unsafe void Test_ReadOnlySpan2DT_GetPinnableReference()
351
351
{
352
352
Assert . IsTrue ( Unsafe . AreSame (
353
353
ref Unsafe . AsRef < int > ( null ) ,
354
- ref ReadOnlySpan2D < int > . Empty . GetPinnableReference ( ) ) ) ;
354
+ ref Unsafe . AsRef ( in ReadOnlySpan2D < int > . Empty . GetPinnableReference ( ) ) ) ) ;
355
355
356
356
int [ , ] array =
357
357
{
@@ -361,7 +361,7 @@ ref Unsafe.AsRef<int>(null),
361
361
362
362
ReadOnlySpan2D < int > span2d = new ( array ) ;
363
363
364
- ref int r0 = ref span2d . GetPinnableReference ( ) ;
364
+ ref int r0 = ref Unsafe . AsRef ( in span2d . GetPinnableReference ( ) ) ;
365
365
366
366
Assert . IsTrue ( Unsafe . AreSame ( ref r0 , ref array [ 0 , 0 ] ) ) ;
367
367
}
You can’t perform that action at this time.
0 commit comments