GrindCore.SharpCompress 0.48.0

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

GrindCore.SharpCompress

GrindCore.SharpCompress is an enhanced version of SharpCompress that integrates GrindCore native compression. This project delivers native compression support built using the System.IO.Compression pattern, utilizing compression algorithms directly from their original C implementations.

This fork replaces GZip, LZMA, Deflate, ZStandard, LZ4, and Brotli implementations with native C streams from GrindCore, providing significant performance improvements while maintaining full API compatibility.

Based on SharpCompress 0.48.0 — includes all upstream features plus native compression.

For more in-depth information, see Ask DeepWiki.

Installation

<PackageReference Include="GrindCore.SharpCompress" Version="0.48.0" />

Format Support

Format Read Write Native Performance Notes
ZIP ✅ (Deflate, ZStd, LZMA) Zip64, PKWare/WinZip AES encryption
TAR ✅ (with compression) GZip, BZip2, LZip, XZ, ZStandard
GZIP Native ZLib-NG
BZIP2 ❌ (managed) Original C# implementation
7ZIP ✅ (LZMA/LZMA2) Non-solid write, seekable streams required
RAR N/A RAR4 and RAR5, solid archives supported
LZIP Native LZMA
XZ Native LZMA2 decompression
ACE N/A Read-only
ARJ N/A Read-only

Compression Algorithms

Algorithm Levels Native Notes
Deflate 1-9 ✅ ZLib-NG v2.2.1 Used in ZIP, GZip, Tar.GZip
LZMA/LZMA2 1-9 ✅ v25.1.0 Block and Solid modes, 7zip writing
ZStandard 1-22 ✅ v1.5.7 ZIP, TAR, standalone
LZ4 1-12 ✅ v1.10.0 7zip decompression, standalone
Brotli 1-11 ✅ v1.1.0 7zip decompression, standalone
BZip2 Fixed Managed C# implementation
PPMd Fixed Managed C# implementation
Deflate64 N/A Decompression only
Shrink/Implode/Reduce N/A Legacy ZIP decompression only

Key Features

Native Compression via GrindCore

  • Native C implementations compiled from original algorithm authors' code
  • No external DLL dependencies — native libraries bundled per platform
  • Multiplatform: Windows (x64/x86/ARM64), Linux (x64/ARM64/ARM), macOS (x64/ARM64)
  • AOT/Trimming compatible on .NET 8+

7-Zip Writing (New in 0.48.0)

  • SevenZipWriter for creating 7z archives with LZMA or LZMA2 compression
  • Non-solid mode (each file compressed independently)
  • Async writing support via WriterFactory.OpenAsyncWriter
  • Requires seekable output stream

Archive Detection API (New in 0.48.0)

  • ArchiveFactory.GetArchiveInformation() — detect archive type without fully opening
  • Consolidated factory helpers for format detection

PooledMemoryStream (New in 0.48.0)

  • ArrayPool<byte>-backed memory stream for reduced GC pressure
  • Used internally for 7zip writing and CRC computation

Zip-Slip Protection (New in 0.48.0)

  • Path traversal protection on extraction
  • Consolidated extraction options via ExtractionOptions

Stream APIs

  • Archive API: Random access with seekable streams (ZipArchive, TarArchive, SevenZipArchive, etc.)
  • Reader API: Forward-only reading on non-seekable streams (ZipReader, TarReader, etc.)
  • Writer API: Forward-only writing (ZipWriter, TarWriter, SevenZipWriter, etc.)
  • Full async/await support with CancellationToken throughout
  • Auto-detection via ReaderFactory.OpenReader() / ArchiveFactory.OpenArchive()

LZMA2 Modes

  • Block Mode: Configurable block sizes for compression/speed balance
  • Solid Mode: Maximum compression (CompressionBufferSize = -1)

Framework Support

  • .NET 10, 9, 8, 7, 6, 5
  • .NET Standard 2.1, 2.0
  • .NET Framework 4.8, 4.8.1
  • NativeAOT compatible (.NET 8+)

Performance

GrindCore native implementations provide measurable improvements over managed C#:

  • Deflate/GZip: 3-5x faster than managed implementation
  • LZ4: 400+ MB/s compression, 1500+ MB/s decompression
  • ZStandard Level 6: 100+ MB/s compression, 400+ MB/s decompression
  • LZMA2 Solid: 95%+ compression ratio on text data
  • Brotli Level 9: Excellent web compression with 85%+ ratio on text

Native implementations leverage modern CPU instruction sets (AVX2, SSE4) where available.

Migration from SharpCompress

This is a drop-in replacement. Change your package reference:


<PackageReference Include="SharpCompress" Version="0.48.0" />


<PackageReference Include="GrindCore.SharpCompress" Version="0.48.0" />

No code changes required. Existing SharpCompress code benefits from native performance automatically.

Usage Examples

// Write a ZIP with ZStandard compression
var options = new WriterOptions(CompressionType.ZStandard) { CompressionLevel = 6 };
using var writer = WriterFactory.OpenWriter(outputStream, ArchiveType.Zip, options);
writer.Write("file.txt", inputStream, DateTime.Now);

// Write a 7zip archive with LZMA2
var options7z = new WriterOptions(CompressionType.LZMA2) { CompressionLevel = 9 };
using var writer7z = WriterFactory.OpenWriter(outputStream, ArchiveType.SevenZip, options7z);
writer7z.Write("data.bin", inputStream, DateTime.Now);

// LZMA2 Solid Mode for maximum compression
var solidOptions = new WriterOptions(CompressionType.LZMA2)
{
    CompressionBufferSize = -1 // Solid mode
};

// Read any archive format (auto-detect)
using var archive = ArchiveFactory.OpenArchive(inputStream);
foreach (var entry in archive.Entries.Where(e => !e.IsDirectory))
{
    entry.WriteToDirectory(outputDir);
}

Architecture

GrindCore.SharpCompress.dll
  → GrindCore.net.dll (.NET stream wrappers)
    → GrindCore.dll (Native C library)

When UseGrindCore=true (default), native stream implementations replace the managed ones at compile time. Set UseGrindCore=false to build with pure managed implementations (matching upstream SharpCompress behaviour).

Documentation

Contributing

Contributions welcome. Areas of interest:

  • Performance benchmarking
  • Platform-specific testing
  • Additional native algorithm integration (BZip2, PPMd)
  • Real-world usage feedback

Please use GitHub issues for support requests.

License

MIT License — same as the original SharpCompress project. Native libraries are licensed as specified in GrindCore documentation.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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 is compatible.  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 is compatible.  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 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. 
.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 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 is compatible. 
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. 
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 GrindCore.SharpCompress:

Package Downloads
SabreTools.Serialization

Serialization and deserialization helpers for various types

BinaryObjectScanner

Protection scanning library

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on GrindCore.SharpCompress:

Repository Stars
SabreTools/MPF
Redumper/Aaru/DiscImageCreator GUI in C#
SabreTools/SabreTools
DAT management tool with advanced editing and sorting features
SabreTools/BinaryObjectScanner
C# protection, packer, and archive scanning library
Version Downloads Last Updated
0.48.0 43 5/8/2026
0.46.2 1,634 2/21/2026
0.44.5 119 2/18/2026
0.42.0 386 12/3/2025
0.41.3 499 11/30/2025
0.41.2 223 11/26/2025
0.41.1 829 11/25/2025
0.41.0 281 11/23/2025
0.40.4-alpha 1,791 9/29/2025
0.40.3-alpha 409 9/6/2025
0.40.2-alpha 172 8/23/2025
0.40.1-alpha 215 8/21/2025
0.40.0-alpha 302 7/28/2025