Rename new Stream.Read/Write{Async} Span/Memory source/Destination arguments to buffe...
authorAnirudh Agnihotry <anirudhagnihotry098@gmail.com>
Fri, 23 Mar 2018 12:43:47 +0000 (05:43 -0700)
committerStephen Toub <stoub@microsoft.com>
Fri, 23 Mar 2018 12:43:47 +0000 (08:43 -0400)
* changed to buffer

* More Common changes

* fixed

* another fix

src/mscorlib/shared/System/IO/FileStream.cs
src/mscorlib/shared/System/IO/MemoryStream.cs
src/mscorlib/shared/System/IO/PinnedBufferMemoryStream.cs
src/mscorlib/shared/System/IO/UnmanagedMemoryStream.cs
src/mscorlib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs
src/mscorlib/src/System/IO/Stream.cs

index 717b73f..a6ad63c 100644 (file)
@@ -304,7 +304,7 @@ namespace System.IO
                 ReadSpan(new Span<byte>(array, offset, count));
         }
 
-        public override int Read(Span<byte> destination)
+        public override int Read(Span<byte> buffer)
         {
             if (GetType() == typeof(FileStream) && !_useAsyncIO)
             {
@@ -312,7 +312,7 @@ namespace System.IO
                 {
                     throw Error.GetFileNotOpen();
                 }
-                return ReadSpan(destination);
+                return ReadSpan(buffer);
             }
             else
             {
@@ -322,7 +322,7 @@ namespace System.IO
                 // of Read(byte[],int,int) overload.  Or if the stream is in async mode, we can't call the
                 // synchronous ReadSpan, so we similarly call the base Read, which will turn delegate to
                 // Read(byte[],int,int), which will do the right thing if we're in async mode.
-                return base.Read(destination);
+                return base.Read(buffer);
             }
         }
 
@@ -355,14 +355,14 @@ namespace System.IO
             return ReadAsyncTask(buffer, offset, count, cancellationToken);
         }
 
-        public override ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken))
+        public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
         {
             if (!_useAsyncIO || GetType() != typeof(FileStream))
             {
                 // If we're not using async I/O, delegate to the base, which will queue a call to Read.
                 // Or if this isn't a concrete FileStream, a derived type may have overridden ReadAsync(byte[],...),
                 // which was introduced first, so delegate to the base which will delegate to that.
-                return base.ReadAsync(destination, cancellationToken);
+                return base.ReadAsync(buffer, cancellationToken);
             }
 
             if (cancellationToken.IsCancellationRequested)
@@ -375,7 +375,7 @@ namespace System.IO
                 throw Error.GetFileNotOpen();
             }
 
-            Task<int> t = ReadAsyncInternal(destination, cancellationToken, out int synchronousResult);
+            Task<int> t = ReadAsyncInternal(buffer, cancellationToken, out int synchronousResult);
             return t != null ?
                 new ValueTask<int>(t) :
                 new ValueTask<int>(synchronousResult);
@@ -412,7 +412,7 @@ namespace System.IO
             }
         }
 
-        public override void Write(ReadOnlySpan<byte> destination)
+        public override void Write(ReadOnlySpan<byte> buffer)
         {
             if (GetType() == typeof(FileStream) && !_useAsyncIO)
             {
@@ -420,7 +420,7 @@ namespace System.IO
                 {
                     throw Error.GetFileNotOpen();
                 }
-                WriteSpan(destination);
+                WriteSpan(buffer);
             }
             else
             {
@@ -430,7 +430,7 @@ namespace System.IO
                 // of Write(byte[],int,int) overload.  Or if the stream is in async mode, we can't call the
                 // synchronous WriteSpan, so we similarly call the base Write, which will turn delegate to
                 // Write(byte[],int,int), which will do the right thing if we're in async mode.
-                base.Write(destination);
+                base.Write(buffer);
             }
         }
 
@@ -461,14 +461,14 @@ namespace System.IO
             return WriteAsyncInternal(new ReadOnlyMemory<byte>(buffer, offset, count), cancellationToken).AsTask();
         }
 
-        public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
+        public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
         {
             if (!_useAsyncIO || GetType() != typeof(FileStream))
             {
                 // If we're not using async I/O, delegate to the base, which will queue a call to Write.
                 // Or if this isn't a concrete FileStream, a derived type may have overridden WriteAsync(byte[],...),
                 // which was introduced first, so delegate to the base which will delegate to that.
-                return base.WriteAsync(source, cancellationToken);
+                return base.WriteAsync(buffer, cancellationToken);
             }
 
             if (cancellationToken.IsCancellationRequested)
@@ -481,7 +481,7 @@ namespace System.IO
                 throw Error.GetFileNotOpen();
             }
 
-            return WriteAsyncInternal(source, cancellationToken);
+            return WriteAsyncInternal(buffer, cancellationToken);
         }
 
         /// <summary>
index ffe7f60..fb319de 100644 (file)
@@ -367,19 +367,19 @@ namespace System.IO
             return n;
         }
 
-        public override int Read(Span<byte> destination)
+        public override int Read(Span<byte> buffer)
         {
             if (GetType() != typeof(MemoryStream))
             {
                 // MemoryStream is not sealed, and a derived type may have overridden Read(byte[], int, int) prior
                 // to this Read(Span<byte>) overload being introduced.  In that case, this Read(Span<byte>) overload
                 // should use the behavior of Read(byte[],int,int) overload.
-                return base.Read(destination);
+                return base.Read(buffer);
             }
 
             EnsureNotClosed();
 
-            int n = Math.Min(_length - _position, destination.Length);
+            int n = Math.Min(_length - _position, buffer.Length);
             if (n <= 0)
                 return 0;
 
@@ -387,7 +387,7 @@ namespace System.IO
             // Read(byte[], int, int) has an n <= 8 optimization, presumably based
             // on benchmarking.  Determine if/where such a cut-off is here and add
             // an equivalent optimization if necessary.
-            new Span<byte>(_buffer, _position, n).CopyTo(destination);
+            new Span<byte>(_buffer, _position, n).CopyTo(buffer);
 
             _position += n;
             return n;
@@ -426,7 +426,7 @@ namespace System.IO
             }
         }
 
-        public override ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken))
+        public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
         {
             if (cancellationToken.IsCancellationRequested)
             {
@@ -448,9 +448,9 @@ namespace System.IO
                 // something other than an array and this is a MemoryStream-derived type that doesn't override Read(Span<byte>) will
                 // it then fall back to doing the ArrayPool/copy behavior.
                 return new ValueTask<int>(
-                    MemoryMarshal.TryGetArray(destination, out ArraySegment<byte> destinationArray) ?
+                    MemoryMarshal.TryGetArray(buffer, out ArraySegment<byte> destinationArray) ?
                         Read(destinationArray.Array, destinationArray.Offset, destinationArray.Count) :
-                        Read(destination.Span));
+                        Read(buffer.Span));
             }
             catch (OperationCanceledException oce)
             {
@@ -681,14 +681,14 @@ namespace System.IO
             _position = i;
         }
 
-        public override void Write(ReadOnlySpan<byte> source)
+        public override void Write(ReadOnlySpan<byte> buffer)
         {
             if (GetType() != typeof(MemoryStream))
             {
                 // MemoryStream is not sealed, and a derived type may have overridden Write(byte[], int, int) prior
                 // to this Write(Span<byte>) overload being introduced.  In that case, this Write(Span<byte>) overload
                 // should use the behavior of Write(byte[],int,int) overload.
-                base.Write(source);
+                base.Write(buffer);
                 return;
             }
 
@@ -696,7 +696,7 @@ namespace System.IO
             EnsureWriteable();
 
             // Check for overflow
-            int i = _position + source.Length;
+            int i = _position + buffer.Length;
             if (i < 0)
                 throw new IOException(SR.IO_StreamTooLong);
 
@@ -718,7 +718,7 @@ namespace System.IO
                 _length = i;
             }
 
-            source.CopyTo(new Span<byte>(_buffer, _position, source.Length));
+            buffer.CopyTo(new Span<byte>(_buffer, _position, buffer.Length));
             _position = i;
         }
 
@@ -752,7 +752,7 @@ namespace System.IO
             }
         }
 
-        public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
+        public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
         {
             if (cancellationToken.IsCancellationRequested)
             {
@@ -763,13 +763,13 @@ namespace System.IO
             {
                 // See corresponding comment in ReadAsync for why we don't just always use Write(ReadOnlySpan<byte>).
                 // Unlike ReadAsync, we could delegate to WriteAsync(byte[], ...) here, but we don't for consistency.
-                if (MemoryMarshal.TryGetArray(source, out ArraySegment<byte> sourceArray))
+                if (MemoryMarshal.TryGetArray(buffer, out ArraySegment<byte> sourceArray))
                 {
                     Write(sourceArray.Array, sourceArray.Offset, sourceArray.Count);
                 }
                 else
                 {
-                    Write(source.Span);
+                    Write(buffer.Span);
                 }
                 return default;
             }
index dfcc05d..94331a2 100644 (file)
@@ -38,9 +38,9 @@ namespace System.IO
                 Initialize(ptr, len, len, FileAccess.Read);
         }
 
-        public override int Read(Span<byte> destination) => ReadCore(destination);
+        public override int Read(Span<byte> buffer) => ReadCore(buffer);
 
-        public override void Write(ReadOnlySpan<byte> source) => WriteCore(source);
+        public override void Write(ReadOnlySpan<byte> buffer) => WriteCore(buffer);
 
         ~PinnedBufferMemoryStream()
         {
index d1a1315..2bcb16f 100644 (file)
@@ -379,22 +379,22 @@ namespace System.IO
             return ReadCore(new Span<byte>(buffer, offset, count));
         }
 
-        public override int Read(Span<byte> destination)
+        public override int Read(Span<byte> buffer)
         {
             if (GetType() == typeof(UnmanagedMemoryStream))
             {
-                return ReadCore(destination);
+                return ReadCore(buffer);
             }
             else
             {
                 // UnmanagedMemoryStream is not sealed, and a derived type may have overridden Read(byte[], int, int) prior
                 // to this Read(Span<byte>) overload being introduced.  In that case, this Read(Span<byte>) overload
                 // should use the behavior of Read(byte[],int,int) overload.
-                return base.Read(destination);
+                return base.Read(buffer);
             }
         }
 
-        internal int ReadCore(Span<byte> destination)
+        internal int ReadCore(Span<byte> buffer)
         {
             EnsureNotClosed();
             EnsureReadable();
@@ -403,7 +403,7 @@ namespace System.IO
             // changes our position after we decide we can read some bytes.
             long pos = Interlocked.Read(ref _position);
             long len = Interlocked.Read(ref _length);
-            long n = Math.Min(len - pos, destination.Length);
+            long n = Math.Min(len - pos, buffer.Length);
             if (n <= 0)
             {
                 return 0;
@@ -418,7 +418,7 @@ namespace System.IO
 
             unsafe
             {
-                fixed (byte* pBuffer = &MemoryMarshal.GetReference(destination))
+                fixed (byte* pBuffer = &MemoryMarshal.GetReference(buffer))
                 {
                     if (_buffer != null)
                     {
@@ -486,9 +486,9 @@ namespace System.IO
         /// <summary>
         /// Reads bytes from stream and puts them into the buffer
         /// </summary>
-        /// <param name="destination">Buffer to read the bytes to.</param>
+        /// <param name="buffer">Buffer to read the bytes to.</param>
         /// <param name="cancellationToken">Token that can be used to cancel this operation.</param>
-        public override ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken))
+        public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
         {
             if (cancellationToken.IsCancellationRequested)
             {
@@ -510,9 +510,9 @@ namespace System.IO
                 // something other than an array and this is an UnmanagedMemoryStream-derived type that doesn't override Read(Span<byte>) will
                 // it then fall back to doing the ArrayPool/copy behavior.
                 return new ValueTask<int>(
-                    MemoryMarshal.TryGetArray(destination, out ArraySegment<byte> destinationArray) ?
+                    MemoryMarshal.TryGetArray(buffer, out ArraySegment<byte> destinationArray) ?
                         Read(destinationArray.Array, destinationArray.Offset, destinationArray.Count) :
-                        Read(destination.Span));
+                        Read(buffer.Span));
             }
             catch (Exception ex)
             {
@@ -659,29 +659,29 @@ namespace System.IO
             WriteCore(new Span<byte>(buffer, offset, count));
         }
 
-        public override void Write(ReadOnlySpan<byte> source)
+        public override void Write(ReadOnlySpan<byte> buffer)
         {
             if (GetType() == typeof(UnmanagedMemoryStream))
             {
-                WriteCore(source);
+                WriteCore(buffer);
             }
             else
             {
                 // UnmanagedMemoryStream is not sealed, and a derived type may have overridden Write(byte[], int, int) prior
                 // to this Write(Span<byte>) overload being introduced.  In that case, this Write(Span<byte>) overload
                 // should use the behavior of Write(byte[],int,int) overload.
-                base.Write(source);
+                base.Write(buffer);
             }
         }
 
-        internal unsafe void WriteCore(ReadOnlySpan<byte> source)
+        internal unsafe void WriteCore(ReadOnlySpan<byte> buffer)
         {
             EnsureNotClosed();
             EnsureWriteable();
 
             long pos = Interlocked.Read(ref _position);  // Use a local to avoid a race condition
             long len = Interlocked.Read(ref _length);
-            long n = pos + source.Length;
+            long n = pos + buffer.Length;
             // Check for overflow
             if (n < 0)
             {
@@ -709,12 +709,12 @@ namespace System.IO
                 }
             }
 
-            fixed (byte* pBuffer = &MemoryMarshal.GetReference(source))
+            fixed (byte* pBuffer = &MemoryMarshal.GetReference(buffer))
             {
                 if (_buffer != null)
                 {
                     long bytesLeft = _capacity - pos;
-                    if (bytesLeft < source.Length)
+                    if (bytesLeft < buffer.Length)
                     {
                         throw new ArgumentException(SR.Arg_BufferTooSmall);
                     }
@@ -724,7 +724,7 @@ namespace System.IO
                     try
                     {
                         _buffer.AcquirePointer(ref pointer);
-                        Buffer.Memcpy(pointer + pos + _offset, pBuffer, source.Length);
+                        Buffer.Memcpy(pointer + pos + _offset, pBuffer, buffer.Length);
                     }
                     finally
                     {
@@ -736,7 +736,7 @@ namespace System.IO
                 }
                 else
                 {
-                    Buffer.Memcpy(_mem + pos, pBuffer, source.Length);
+                    Buffer.Memcpy(_mem + pos, pBuffer, buffer.Length);
                 }
             }
 
@@ -783,7 +783,7 @@ namespace System.IO
         /// </summary>
         /// <param name="buffer">Buffer that will be written.</param>
         /// <param name="cancellationToken">Token that can be used to cancel the operation.</param>
-        public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
+        public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
         {
             if (cancellationToken.IsCancellationRequested)
             {
@@ -794,13 +794,13 @@ namespace System.IO
             {
                 // See corresponding comment in ReadAsync for why we don't just always use Write(ReadOnlySpan<byte>).
                 // Unlike ReadAsync, we could delegate to WriteAsync(byte[], ...) here, but we don't for consistency.
-                if (MemoryMarshal.TryGetArray(source, out ArraySegment<byte> sourceArray))
+                if (MemoryMarshal.TryGetArray(buffer, out ArraySegment<byte> sourceArray))
                 {
                     Write(sourceArray.Array, sourceArray.Offset, sourceArray.Count);
                 }
                 else
                 {
-                    Write(source.Span);
+                    Write(buffer.Span);
                 }
                 return default;
             }
index f34c3c4..65a3396 100644 (file)
@@ -112,9 +112,9 @@ namespace System.IO
             return _unmanagedStream.Read(buffer, offset, count);
         }
 
-        public override int Read(Span<byte> destination)
+        public override int Read(Span<byte> buffer)
         {
-            return _unmanagedStream.Read(destination);
+            return _unmanagedStream.Read(buffer);
         }
 
         public override int ReadByte()
@@ -139,9 +139,9 @@ namespace System.IO
             _unmanagedStream.Write(buffer, offset, count);
         }
 
-        public override void Write(ReadOnlySpan<byte> source)
+        public override void Write(ReadOnlySpan<byte> buffer)
         {
-            _unmanagedStream.Write(source);
+            _unmanagedStream.Write(buffer);
         }
 
         public override void WriteByte(byte value)
@@ -206,9 +206,9 @@ namespace System.IO
             return _unmanagedStream.ReadAsync(buffer, offset, count, cancellationToken);
         }
 
-        public override ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken))
+        public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
         {
-            return _unmanagedStream.ReadAsync(destination, cancellationToken);
+            return _unmanagedStream.ReadAsync(buffer, cancellationToken);
         }
 
 
@@ -217,9 +217,9 @@ namespace System.IO
             return _unmanagedStream.WriteAsync(buffer, offset, count, cancellationToken);
         }
 
-        public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
+        public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
         {
-            return _unmanagedStream.WriteAsync(source, cancellationToken);
+            return _unmanagedStream.WriteAsync(buffer, cancellationToken);
         }
     }  // class UnmanagedMemoryStreamWrapper
 }  // namespace
index ec29dc2..4cf8435 100644 (file)
@@ -374,16 +374,16 @@ namespace System.IO
                         : BeginEndReadAsync(buffer, offset, count);
         }
 
-        public virtual ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken))
+        public virtual ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
         {
-            if (MemoryMarshal.TryGetArray(destination, out ArraySegment<byte> array))
+            if (MemoryMarshal.TryGetArray(buffer, out ArraySegment<byte> array))
             {
                 return new ValueTask<int>(ReadAsync(array.Array, array.Offset, array.Count, cancellationToken));
             }
             else
             {
-                byte[] buffer = ArrayPool<byte>.Shared.Rent(destination.Length);
-                return FinishReadAsync(ReadAsync(buffer, 0, destination.Length, cancellationToken), buffer, destination);
+                byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length);
+                return FinishReadAsync(ReadAsync(sharedBuffer, 0, buffer.Length, cancellationToken), sharedBuffer, buffer);
 
                 async ValueTask<int> FinishReadAsync(Task<int> readTask, byte[] localBuffer, Memory<byte> localDestination)
                 {
@@ -683,17 +683,17 @@ namespace System.IO
                         : BeginEndWriteAsync(buffer, offset, count);
         }
 
-        public virtual ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
+        public virtual ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
         {
-            if (MemoryMarshal.TryGetArray(source, out ArraySegment<byte> array))
+            if (MemoryMarshal.TryGetArray(buffer, out ArraySegment<byte> array))
             {
                 return new ValueTask(WriteAsync(array.Array, array.Offset, array.Count, cancellationToken));
             }
             else
             {
-                byte[] buffer = ArrayPool<byte>.Shared.Rent(source.Length);
-                source.Span.CopyTo(buffer);
-                return new ValueTask(FinishWriteAsync(WriteAsync(buffer, 0, source.Length, cancellationToken), buffer));
+                byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length);
+                buffer.Span.CopyTo(sharedBuffer);
+                return new ValueTask(FinishWriteAsync(WriteAsync(sharedBuffer, 0, buffer.Length, cancellationToken), sharedBuffer));
             }
         }
 
@@ -738,20 +738,20 @@ namespace System.IO
 
         public abstract int Read(byte[] buffer, int offset, int count);
 
-        public virtual int Read(Span<byte> destination)
+        public virtual int Read(Span<byte> buffer)
         {
-            byte[] buffer = ArrayPool<byte>.Shared.Rent(destination.Length);
+            byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length);
             try
             {
-                int numRead = Read(buffer, 0, destination.Length);
-                if ((uint)numRead > destination.Length)
+                int numRead = Read(sharedBuffer, 0, buffer.Length);
+                if ((uint)numRead > buffer.Length)
                 {
                     throw new IOException(SR.IO_StreamTooLong);
                 }
-                new Span<byte>(buffer, 0, numRead).CopyTo(destination);
+                new Span<byte>(sharedBuffer, 0, numRead).CopyTo(buffer);
                 return numRead;
             }
-            finally { ArrayPool<byte>.Shared.Return(buffer); }
+            finally { ArrayPool<byte>.Shared.Return(sharedBuffer); }
         }
 
         // Reads one byte from the stream by calling Read(byte[], int, int). 
@@ -771,15 +771,15 @@ namespace System.IO
 
         public abstract void Write(byte[] buffer, int offset, int count);
 
-        public virtual void Write(ReadOnlySpan<byte> source)
+        public virtual void Write(ReadOnlySpan<byte> buffer)
         {
-            byte[] buffer = ArrayPool<byte>.Shared.Rent(source.Length);
+            byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length);
             try
             {
-                source.CopyTo(buffer);
-                Write(buffer, 0, source.Length);
+                buffer.CopyTo(sharedBuffer);
+                Write(sharedBuffer, 0, buffer.Length);
             }
-            finally { ArrayPool<byte>.Shared.Return(buffer); }
+            finally { ArrayPool<byte>.Shared.Return(sharedBuffer); }
         }
 
         // Writes one byte from the stream by calling Write(byte[], int, int).
@@ -972,7 +972,7 @@ namespace System.IO
                 return 0;
             }
 
-            public override int Read(Span<byte> destination)
+            public override int Read(Span<byte> buffer)
             {
                 return 0;
             }
@@ -982,7 +982,7 @@ namespace System.IO
                 return AsyncTaskMethodBuilder<int>.s_defaultResultTask;
             }
 
-            public override ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken))
+            public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
             {
                 return new ValueTask<int>(0);
             }
@@ -996,7 +996,7 @@ namespace System.IO
             {
             }
 
-            public override void Write(ReadOnlySpan<byte> source)
+            public override void Write(ReadOnlySpan<byte> buffer)
             {
             }
 
@@ -1007,7 +1007,7 @@ namespace System.IO
                     Task.CompletedTask;
             }
 
-            public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
+            public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
             {
                 return cancellationToken.IsCancellationRequested ?
                     new ValueTask(Task.FromCanceled(cancellationToken)) :
@@ -1256,10 +1256,10 @@ namespace System.IO
                     return _stream.Read(bytes, offset, count);
             }
 
-            public override int Read(Span<byte> destination)
+            public override int Read(Span<byte> buffer)
             {
                 lock (_stream)
-                    return _stream.Read(destination);
+                    return _stream.Read(buffer);
             }
 
             public override int ReadByte()
@@ -1313,10 +1313,10 @@ namespace System.IO
                     _stream.Write(bytes, offset, count);
             }
 
-            public override void Write(ReadOnlySpan<byte> source)
+            public override void Write(ReadOnlySpan<byte> buffer)
             {
                 lock (_stream)
-                    _stream.Write(source);
+                    _stream.Write(buffer);
             }
 
             public override void WriteByte(byte b)