Remove Span DangerousGetPinnableReference
authorIan Hays <ianha@microsoft.com>
Tue, 30 Jan 2018 18:58:52 +0000 (10:58 -0800)
committerJan Kotas <jkotas@microsoft.com>
Wed, 31 Jan 2018 17:33:07 +0000 (09:33 -0800)
src/mscorlib/shared/System/ReadOnlySpan.cs
src/mscorlib/shared/System/Runtime/InteropServices/MemoryMarshal.Fast.cs
src/mscorlib/shared/System/Span.cs

index e97364e..56d0ad9 100644 (file)
@@ -113,17 +113,6 @@ namespace System
         }
 
         /// <summary>
-        /// Returns a reference to the 0th element of the Span. If the Span is empty, returns a reference to the location where the 0th element
-        /// would have been stored. Such a reference can be used for pinning but must never be dereferenced.
-        /// </summary>
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        internal ref readonly T DangerousGetPinnableReference()
-        {
-            return ref _pointer.Value;
-        }
-
-        /// <summary>
         /// The number of items in the read-only span.
         /// </summary>
         public int Length
@@ -194,7 +183,7 @@ namespace System
 
             if ((uint)_length <= (uint)destination.Length)
             {
-                Buffer.Memmove(ref destination.DangerousGetPinnableReference(), ref _pointer.Value, (nuint)_length);
+                Buffer.Memmove(ref destination._pointer.Value, ref _pointer.Value, (nuint)_length);
             }
             else
             {
@@ -214,7 +203,7 @@ namespace System
             bool retVal = false;
             if ((uint)_length <= (uint)destination.Length)
             {
-                Buffer.Memmove(ref destination.DangerousGetPinnableReference(), ref _pointer.Value, (nuint)_length);
+                Buffer.Memmove(ref destination._pointer.Value, ref _pointer.Value, (nuint)_length);
                 retVal = true;
             }
             return retVal;
index 6362209..967459e 100644 (file)
@@ -60,7 +60,7 @@ namespace System.Runtime.InteropServices
                 ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(TTo));
 
             return new Span<TTo>(
-                ref Unsafe.As<TFrom, TTo>(ref source.DangerousGetPinnableReference()),
+                ref Unsafe.As<TFrom, TTo>(ref source._pointer.Value),
                 checked((int)((long)source.Length * Unsafe.SizeOf<TFrom>() / Unsafe.SizeOf<TTo>())));
         }
 
index 22be6b7..e14dac7 100644 (file)
@@ -119,17 +119,6 @@ namespace System
         }
 
         /// <summary>
-        /// Returns a reference to the 0th element of the Span. If the Span is empty, returns a reference to the location where the 0th element
-        /// would have been stored. Such a reference can be used for pinning but must never be dereferenced.
-        /// </summary>
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        internal ref T DangerousGetPinnableReference()
-        {
-            return ref _pointer.Value;
-        }
-
-        /// <summary>
         /// The number of items in the span.
         /// </summary>
         public int Length
@@ -219,7 +208,7 @@ namespace System
                 if (length == 0)
                     return;
 
-                ref T r = ref DangerousGetPinnableReference();
+                ref T r = ref _pointer.Value;
 
                 // TODO: Create block fill for value types of power of two sizes e.g. 2,4,8,16
 
@@ -268,7 +257,7 @@ namespace System
 
             if ((uint)_length <= (uint)destination.Length)
             {
-                Buffer.Memmove(ref destination.DangerousGetPinnableReference(), ref _pointer.Value, (nuint)_length);
+                Buffer.Memmove(ref destination._pointer.Value, ref _pointer.Value, (nuint)_length);
             }
             else
             {
@@ -289,7 +278,7 @@ namespace System
             bool retVal = false;
             if ((uint)_length <= (uint)destination.Length)
             {
-                Buffer.Memmove(ref destination.DangerousGetPinnableReference(), ref _pointer.Value, (nuint)_length);
+                Buffer.Memmove(ref destination._pointer.Value, ref _pointer.Value, (nuint)_length);
                 retVal = true;
             }
             return retVal;