Skip to content
Browse files
Implement Span<byte>/ReadOnlySpan<byte> overloads
Addresses #66

.NET Core 2.1 implements Read and Write overloads that accept Span
constructs. These constructs will work without overloading, but the
default implementations work via inefficient byte array copies.

This adds a netcoreapp2.1 target to the NuGet package, and implements
efficient overloads of Read(Span<byte>) and Write(ReadOnlySpan<byte>).
Overloads of ReadAsync and WriteAsync are not required, they have
efficient default implementations that will use these methods as needed.

The unit tests have also been updated to target .NET Core 2.1 so that
they can test the new method implementations.
  • Loading branch information
brantburnett committed Apr 5, 2019
1 parent 9de4de0 commit 86fc159750fccd66e916133a80f8f33df3cbd1f7
Showing with 508 additions and 4 deletions.
  1. +1 −1 UnitTests/RecyclableMemoryStreamEventListener.cs
  2. +380 −0 UnitTests/Tests.cs
  3. +4 −2 UnitTests/UnitTests.csproj
  4. +1 −1 src/Microsoft.IO.RecyclableMemoryStream.csproj
  5. +122 −0 src/RecyclableMemoryStream.cs
@@ -43,7 +43,7 @@ protected override void OnEventWritten(EventWrittenEventArgs eventData)
this.EventWritten(eventData.EventId, (string)eventData.Payload[TagIndex]);

public virtual void EventWritten(int eventId, string tag)
public new virtual void EventWritten(int eventId, string tag)
switch (eventId)

0 comments on commit 86fc159

Please sign in to comment.