Soenneker.MemoryStream.ManualClose 4.0.696

Prefix Reserved
dotnet add package Soenneker.MemoryStream.ManualClose --version 4.0.696
                    
NuGet\Install-Package Soenneker.MemoryStream.ManualClose -Version 4.0.696
                    
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.MemoryStream.ManualClose" Version="4.0.696" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.MemoryStream.ManualClose" Version="4.0.696" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.MemoryStream.ManualClose" />
                    
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.MemoryStream.ManualClose --version 4.0.696
                    
#r "nuget: Soenneker.MemoryStream.ManualClose, 4.0.696"
                    
#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.MemoryStream.ManualClose@4.0.696
                    
#: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.MemoryStream.ManualClose&version=4.0.696
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.MemoryStream.ManualClose&version=4.0.696
                    
Install as a Cake Tool

Soenneker.MemoryStream.ManualClose

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

A MemoryStream whose Close and Dispose calls can be temporarily ignored when another API incorrectly assumes ownership of a caller-owned stream.

Installation

dotnet add package Soenneker.MemoryStream.ManualClose

Usage

AllowClose defaults to true, so the stream behaves like a normal MemoryStream unless closing is explicitly blocked.

var stream = new ManualCloseMemoryStream
{
    AllowClose = false
};

try
{
    await WritePayload(stream);

    // This dependency calls Dispose on the supplied stream.
    await SendWithoutOwnership(stream);

    // The stream remains usable because closing was blocked.
    stream.Position = 0;
    await SaveCopy(stream);
}
finally
{
    stream.AllowClose = true;
    stream.Dispose();
}

Always restore AllowClose and dispose in a finally block. While closing is blocked, a using statement or an early Dispose call does not release the stream's buffer.

This type is useful only when an API closes a stream it does not own and offers no leave-open option. Prefer the dependency's native leaveOpen setting when one exists. Do not change AllowClose concurrently with disposal; the property does not provide synchronization.

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
4.0.696 34 9/24/2026
4.0.695 167 9/15/2026
4.0.694 94 9/12/2026
4.0.693 129 8/30/2026
4.0.692 99 8/29/2026
4.0.691 303 7/27/2026
4.0.690 118 7/16/2026
4.0.689 1,303 6/18/2026
4.0.688 214 6/5/2026
4.0.687 129 6/5/2026
4.0.685 485 3/12/2026
4.0.684 140 3/12/2026
4.0.683 142 3/12/2026
4.0.682 142 3/12/2026
4.0.681 148 3/10/2026
4.0.680 143 3/9/2026
4.0.679 137 3/9/2026
4.0.678 140 3/9/2026
4.0.677 349 3/4/2026
4.0.676 335 1/2/2026
Loading failed

Enable Native AOT compatibility analysis