Universal.Common.IO.Compression
1.3.0
See the version list below for details.
dotnet add package Universal.Common.IO.Compression --version 1.3.0
NuGet\Install-Package Universal.Common.IO.Compression -Version 1.3.0
<PackageReference Include="Universal.Common.IO.Compression" Version="1.3.0" />
<PackageVersion Include="Universal.Common.IO.Compression" Version="1.3.0" />
<PackageReference Include="Universal.Common.IO.Compression" />
paket add Universal.Common.IO.Compression --version 1.3.0
#r "nuget: Universal.Common.IO.Compression, 1.3.0"
#:package Universal.Common.IO.Compression@1.3.0
#addin nuget:?package=Universal.Common.IO.Compression&version=1.3.0
#tool nuget:?package=Universal.Common.IO.Compression&version=1.3.0
Universal.Common.IO.Compression
Compression codecs with no third-party package dependencies: Deflate, Gzip, Zlib, Brotli, Snappy, raw and Hadoop-framed LZ4, raw LZO1X, LZMA (classic and Unity-header variants), and Zstandard. Zstandard checksum validation uses Microsoft's System.IO.Hashing package.
Self-describing formats implement ICompressionAlgorithm. Deflate, Gzip, and Zlib also implement IStreamingCompressionAlgorithm. Raw LZ4 blocks implement ISizedCompressionAlgorithm because their uncompressed size is supplied separately.
Snappy and Zstandard additionally accept an expected decoded size through ISizedCompressionAlgorithm. Raw LZO1X and Hadoop LZ4 require the size. LZO1X encoding currently emits literal-only blocks. GZIP handles concatenated members on .NET Framework as well as modern .NET; the legacy runtime compatibility path reads compressed bytes individually to preserve member boundaries.
Quickstart
// LZ4 (ISizedCompressionAlgorithm - raw block format needs the original size to decompress)
Lz4CompressionAlgorithm lz4 = new Lz4CompressionAlgorithm();
byte[] lz4Compressed = lz4.Compress(data);
byte[] lz4Restored = lz4.Decompress(lz4Compressed, data.Length);
// LZMA, Zstandard, Deflate, Gzip, Zlib
LzmaCompressionAlgorithm lzma = new LzmaCompressionAlgorithm();
byte[] lzmaCompressed = lzma.Compress(data);
byte[] lzmaRestored = lzma.Decompress(lzmaCompressed);
ZstdCompressionAlgorithm zstd = new ZstdCompressionAlgorithm();
byte[] restored2 = zstd.Decompress(zstdCompressedBytes);
IStreamingCompressionAlgorithm zlib = new ZlibCompressionAlgorithm();
using Stream decompressor = zlib.CreateDecompressionStream(compressedInput);
decompressor.CopyTo(output);
// For zlib, compressedInput is now positioned immediately after this member.
// Limit decompression to one member embedded in a larger stream.
using Stream member = zlib.CreateDecompressionStream(container, compressedLength, leaveOpen: true);
await member.CopyToAsync(output);
// End-to-end asynchronous helpers are available for every streaming codec.
await zlib.CompressAsync(input, compressedOutput, cancellationToken);
await zlib.DecompressAsync(compressedInput, output, cancellationToken);
Status
- Brotli: managed RFC 7932 decoder, including context modeling, static dictionary transforms, and all standard window sizes. The encoder emits conforming uncompressed metablocks. Tests cross-check native BCL Brotli across compression qualities, windows, and input patterns. Canonical dictionary and transform data carry the MIT license in
licenses/Brotli-MIT.txt; provenance and a data generation script are underBrotli. - LZ4, LZMA (+ Unity's own header variant): full encode and decode, verified byte-for-byte in both directions against independent real-world implementations (
lz4js, Python'slzmamodule). - Zstandard: full decoder (frame/block parsing, FSE with predefined or custom tables, Huffman-coded literals, sequence execution) - verified against real Zstandard-compressed data, including actual Figma-exported
.figfiles. The encoder currently emits valid, standards-compliant frames using Raw/RLE blocks only (real data any conforming decoder reads correctly, just not entropy-coded) - full FSE/Huffman encoding is its own follow-up. - Deflate, Gzip, Zlib: synchronous and asynchronous streaming encode and decode. Zlib validates its header and Adler-32 checksum, supports non-seekable inputs, and leaves following members or container data unread.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.IO.Hashing (>= 11.0.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Universal.Common.IO.Compression:
| Package | Downloads |
|---|---|
|
Universal.Common.Formats.Fig
Reads and writes Figma .fig file containers and their Kiwi-encoded document data. |
|
|
Universal.Meta.WhatsApp.Client
WebSocket client for the WhatsApp multi-device protocol. |
|
|
Universal.Git
A Git-compatible repository implementation built on Universal.VersionControl. |
|
|
Universal.Apache.Parquet
Managed Apache Parquet file reading and writing. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Added managed Brotli, Snappy, raw LZO1X, and Hadoop-framed LZ4 codecs. Brotli includes MIT-licensed normative dictionary and transform data. Fixed LZ4 final-match boundaries and concatenated GZIP decoding on .NET Framework. Zstandard decoding validates checksums and decoded-size limits and reads concatenated and skippable frames.