Merge pull request dotnet/corert#5109 from dotnet/nmirror (#15518)
authordotnet bot <dotnet-bot@dotnetfoundation.org>
Thu, 14 Dec 2017 06:16:23 +0000 (22:16 -0800)
committerJan Kotas <jkotas@microsoft.com>
Thu, 14 Dec 2017 06:16:23 +0000 (01:16 -0500)
Merge nmirror to master

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
src/mscorlib/shared/System/ReadOnlySpan.cs

index a09314d..fdee601 100644 (file)
@@ -165,15 +165,18 @@ namespace System
         /// <exception cref="System.IndexOutOfRangeException">
         /// Thrown when index less than 0 or index greater than or equal to Length
         /// </exception>
-        public T this[int index]
-        {
 #if PROJECTN
+        public ref readonly T this[int index]
+        {
             [BoundsChecking]
             get
             {
-                return Unsafe.Add(ref _pointer.Value, index);
+                return ref Unsafe.Add(ref _pointer.Value, index);
             }
+        }
 #else
+        public T this[int index]
+        {
             [Intrinsic]
             [MethodImpl(MethodImplOptions.AggressiveInlining)]
             [NonVersionable]
@@ -183,8 +186,8 @@ namespace System
                     ThrowHelper.ThrowIndexOutOfRangeException();
                 return Unsafe.Add(ref _pointer.Value, index);
             }
-#endif
         }
+#endif
 
         /// <summary>
         /// Copies the contents of this read-only span into destination span. If the source