Shuttle.Core.Compression 21.0.1-beta

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

Shuttle.Core.Compression

Provides a compression adapter through the ICompressionAlgorithm interface.

Implementations available in this package:

  • DeflateCompressionAlgorithm (name: "Deflate")
  • GZipCompressionAlgorithm (name: "GZip")
  • NullCompressionAlgorithm (name: "null")

There is also an ICompressionService that acts as a central container for all registered ICompressionAlgorithm implementations.

Installation

dotnet add package Shuttle.Core.Compression

Algorithm Names

When retrieving algorithms from the service, use these exact names:

  • "GZip" - For GZip compression
  • "Deflate" - For Deflate compression
  • "null" - For null/pass-through compression (useful for testing scenarios or when compression needs to be disabled)

Configuration

In order to add compression:

services.AddCompression();

This will try to add the CompressionService singleton.

In order to add specific compression algorithms use the relevant builder calls:

services.AddCompression(builder => {
	builder.AddGZip();
	builder.AddDeflate();
	builder.AddNull();
});

Note: The AddGZip(), AddDeflate(), and AddNull() methods are provided as extension methods from separate files.

Usage

The ICompressionService can be injected into any class that requires compression services:

Using Byte Arrays

var algorithm = compressionService.Get("algorithm-name");
var compressed = await algorithm.CompressAsync(Encoding.UTF8.GetBytes("some data"));
var decompressed = await algorithm.DecompressAsync(compressed);

Using Streams

Convenient extension methods are available for working with streams:

using var inputStream = new MemoryStream(Encoding.UTF8.GetBytes("some data"));
await using var compressedStream = await algorithm.CompressAsync(inputStream);
await using var decompressedStream = await algorithm.DecompressAsync(compressedStream);

using var reader = new StreamReader(decompressedStream);
var result = await reader.ReadToEndAsync();

Performance Considerations

The compression algorithms use a MemoryStreamCache manager to optimize memory allocation and reduce garbage collection pressure. This cached memory pool improves performance for frequent compression/decompression operations.

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.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Shuttle.Core.Compression:

Package Downloads
Shuttle.Esb

Contains the core Shuttle.Esb assembly that should always be referenced when building Shuttle.Esb solutions.

Shuttle.Recall

Event sourcing mechanism.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
21.0.1-beta 132 2/7/2026
21.0.0-alpha 120 1/18/2026
20.0.0 4,348 2/2/2025
12.0.1 5,363 5/3/2024
12.0.0 1,533 4/30/2024
11.0.1 16,740 12/1/2022
11.0.0 28,120 9/4/2022
10.0.4 48,892 11/26/2020
10.0.3 707 11/23/2020
10.0.2 102,053 7/3/2018
10.0.0 22,989 1/2/2018