From ab9ed1146fa90adf4ce5b23c95a61744f2e65566 Mon Sep 17 00:00:00 2001 From: sakno Date: Wed, 25 Oct 2023 21:12:04 +0300 Subject: [PATCH] Fixed regression of WriterAsReadOnlyCollection test --- src/DotNext/Buffers/PooledArrayBufferWriter.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/DotNext/Buffers/PooledArrayBufferWriter.cs b/src/DotNext/Buffers/PooledArrayBufferWriter.cs index af8593050..5ad48ea36 100644 --- a/src/DotNext/Buffers/PooledArrayBufferWriter.cs +++ b/src/DotNext/Buffers/PooledArrayBufferWriter.cs @@ -104,7 +104,10 @@ public ArrayPool? BufferPool /// void ICollection.CopyTo(T[] array, int arrayIndex) - => buffer.CopyTo(array.AsSpan(arrayIndex, position)); + { + var source = MemoryMarshal.CreateReadOnlySpan(ref MemoryMarshal.GetArrayDataReference(buffer), position); + source.CopyTo(array.AsSpan(arrayIndex)); + } /// /// Gets the element at the specified index.