@@ -306,7 +306,7 @@ public void WriteUtf16(string? value)
306306 Unsafe . WriteUnaligned ( ref dest , value . Length ) ;
307307
308308#if NET7_0_OR_GREATER
309- ref var src = ref Unsafe . As < char , byte > ( ref Unsafe . AsRef ( value . GetPinnableReference ( ) ) ) ;
309+ ref var src = ref Unsafe . As < char , byte > ( ref Unsafe . AsRef ( in value . GetPinnableReference ( ) ) ) ;
310310 Unsafe . CopyBlockUnaligned ( ref Unsafe . Add ( ref dest , 4 ) , ref src , ( uint ) copyByteCount ) ;
311311#else
312312 MemoryMarshal . AsBytes ( value . AsSpan ( ) ) . CopyTo ( MemoryMarshal . CreateSpan ( ref Unsafe . Add ( ref dest , 4 ) , copyByteCount ) ) ;
@@ -405,7 +405,7 @@ public void WritePackable<T>(scoped in T? value)
405405 {
406406 depth ++ ;
407407 if ( depth == DepthLimit ) MemoryPackSerializationException . ThrowReachedDepthLimit ( typeof ( T ) ) ;
408- T . Serialize ( ref this , ref Unsafe . AsRef ( value ) ) ;
408+ T . Serialize ( ref this , ref Unsafe . AsRef ( in value ) ) ;
409409 depth -- ;
410410 }
411411
@@ -426,7 +426,7 @@ public void WriteValue<T>(scoped in T? value)
426426 {
427427 depth ++ ;
428428 if ( depth == DepthLimit ) MemoryPackSerializationException . ThrowReachedDepthLimit ( typeof ( T ) ) ;
429- GetFormatter < T > ( ) . Serialize ( ref this , ref Unsafe . AsRef ( value ) ) ;
429+ GetFormatter < T > ( ) . Serialize ( ref this , ref Unsafe . AsRef ( in value ) ) ;
430430 depth -- ;
431431 }
432432
@@ -444,7 +444,7 @@ public void WriteValueWithFormatter<TFormatter, T>(TFormatter formatter, scoped
444444 where TFormatter : IMemoryPackFormatter < T >
445445 {
446446 depth ++ ;
447- formatter . Serialize ( ref this , ref Unsafe . AsRef ( value ) ) ;
447+ formatter . Serialize ( ref this , ref Unsafe . AsRef ( in value ) ) ;
448448 depth -- ;
449449 }
450450
@@ -503,7 +503,7 @@ public void WriteSpan<T>(scoped ReadOnlySpan<T?> value)
503503 WriteCollectionHeader ( value . Length ) ;
504504 for ( int i = 0 ; i < value . Length ; i ++ )
505505 {
506- formatter . Serialize ( ref this , ref Unsafe . AsRef ( value [ i ] ) ) ;
506+ formatter . Serialize ( ref this , ref Unsafe . AsRef ( in value [ i ] ) ) ;
507507 }
508508 }
509509
@@ -575,7 +575,7 @@ public void WritePackableSpan<T>(scoped ReadOnlySpan<T?> value)
575575 WriteCollectionHeader ( value . Length ) ;
576576 for ( int i = 0 ; i < value . Length ; i ++ )
577577 {
578- T . Serialize ( ref this , ref Unsafe . AsRef ( value [ i ] ) ) ;
578+ T . Serialize ( ref this , ref Unsafe . AsRef ( in value [ i ] ) ) ;
579579 }
580580#endif
581581 }
@@ -697,7 +697,7 @@ public void WriteSpanWithoutLengthHeader<T>(scoped ReadOnlySpan<T?> value)
697697 var formatter = GetFormatter < T > ( ) ;
698698 for ( int i = 0 ; i < value . Length ; i ++ )
699699 {
700- formatter . Serialize ( ref this , ref Unsafe . AsRef ( value [ i ] ) ) ;
700+ formatter . Serialize ( ref this , ref Unsafe . AsRef ( in value [ i ] ) ) ;
701701 }
702702 }
703703 }
0 commit comments