Soenneker.Extensions.MemoryStream 4.0.622

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Extensions.MemoryStream --version 4.0.622
                    
NuGet\Install-Package Soenneker.Extensions.MemoryStream -Version 4.0.622
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Extensions.MemoryStream" Version="4.0.622" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Extensions.MemoryStream" Version="4.0.622" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Extensions.MemoryStream" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Extensions.MemoryStream --version 4.0.622
                    
#r "nuget: Soenneker.Extensions.MemoryStream, 4.0.622"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Extensions.MemoryStream@4.0.622
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Extensions.MemoryStream&version=4.0.622
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.MemoryStream&version=4.0.622
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Extensions.MemoryStream

Extension methods for working with MemoryStream instances, including efficient buffer access, conversion, positioning, and other common stream operations.

Installation

dotnet add package Soenneker.Extensions.MemoryStream

Expose the valid buffer without copying

using Soenneker.Extensions.MemoryStream;

using var stream = new MemoryStream();
stream.Write([1, 2, 3]);

ReadOnlyMemory<byte> bytes = stream.ToReadOnlyMemoryBytes(); // [1, 2, 3]

ToReadOnlyMemoryBytes() returns a zero-copy ReadOnlyMemory<byte> view over the stream's valid underlying buffer segment. The stream's current Position does not affect the returned range.

For a stream created over an array segment, the returned memory begins at that segment's offset rather than at index zero of the underlying array:

byte[] buffer = [99, 1, 2, 3, 88];
using var stream = new MemoryStream(buffer, 1, 3, writable: false, publiclyVisible: true);

ReadOnlyMemory<byte> bytes = stream.ToReadOnlyMemoryBytes(); // [1, 2, 3]

Because the memory aliases the stream buffer, later writes through the stream or another owner of the array can be visible through the returned memory. ReadOnlyMemory<byte> prevents mutation through this particular view; it does not make the underlying bytes immutable or create a snapshot. Call ToArray() on the returned memory when an independent copy is required.

Buffer visibility must be permitted. A MemoryStream created over a non-publicly-visible external buffer throws UnauthorizedAccessException. A null or disposed/inaccessible stream follows the underlying MemoryStream buffer APIs' exception behavior.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.636 69 11/18/2026
11.0.635 212 11/11/2026
11.0.634 94 11/10/2026
11.0.633 407 10/27/2026
11.0.632 132 10/26/2026
11.0.631 110 10/26/2026
4.0.630 182 10/14/2026
4.0.629 114 10/14/2026
4.0.624 119 10/12/2026
4.0.623 108 10/12/2026
4.0.622 124 10/11/2026
4.0.621 166 9/24/2026
4.0.620 194 9/15/2026
4.0.619 133 9/12/2026
4.0.618 614 8/30/2026
4.0.617 148 8/29/2026
4.0.615 139 8/29/2026
4.0.614 130 8/29/2026
4.0.613 150 7/27/2026
4.0.612 150 7/16/2026
Loading failed

Fix release metadata shell injection