Eternal.LZMA2SimpleCS 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package Eternal.LZMA2SimpleCS --version 1.0.5
                    
NuGet\Install-Package Eternal.LZMA2SimpleCS -Version 1.0.5
                    
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="Eternal.LZMA2SimpleCS" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Eternal.LZMA2SimpleCS" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Eternal.LZMA2SimpleCS" />
                    
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 Eternal.LZMA2SimpleCS --version 1.0.5
                    
#r "nuget: Eternal.LZMA2SimpleCS, 1.0.5"
                    
#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 Eternal.LZMA2SimpleCS@1.0.5
                    
#: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=Eternal.LZMA2SimpleCS&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Eternal.LZMA2SimpleCS&version=1.0.5
                    
Install as a Cake Tool

Eternal Lzma2Simple

Eternal.Lzma2SimpleCS NuGet library package

Copyright Eternal Developments, LLC. All Rights Reserved.

License

MIT

Functionality

Lzma2Simple

A simplified library to compress and decompress using the 7-Zip libary. It has targets for Windows x64, Linux x64, and C# and is based on the 25.01 version of 7-Zip.

I am working on another project that uses 7-Zip extensively; basically, I compress many smaller blocks in C++ and then visualize in PaintDotNET. This meant I needed a solid C# implementation of the decompressor. As the reference implementation uses macros extensively, a direct port of the C code to C# was not practical. What I did was convert the C code to C++, removed a lot of the dead code, and removed several of the unused options.

I also simplified the usage interface significantly.

The biggest limitation is that C# does not support arrays greater than 2GB. This means files greater than 2GB can't be compressed or decompressed with the C# library. The Array helpers (such as Fill and Copy) all take 64 bit indices, so maybe future versions will.

Usage: // A source buffer with the uncompressed data. A destination buffer with enough storage to store the worst possible compression. CLzmaData data; // Encoder properties - defaults are set in the constructor. CLzma1EncoderProperties encoder1_properties; // The result of the compression CLzma1Result compress_result; // The memory interface can be used to override all memory operation, and the progress interface can be used to report progress Lzma1Compress( &data, encoder_properties, &compress_result, &memory_interface, &progress_interface );

Note: the compress_result returns an array of 5 bytes that need passing into the decompressor

// A source buffer with the compressed data. A destionation buffer set to the size of the decompressed data.
CLzmaData data; 
CLzma1Result decompess_result;
memcpy_s( decompress_result.Properties, 5, compress_result.properties, 5 );
Lzma1Decompress( &decompress, &result, &memory_interface );

A very similar process is used for Lzma2. The differences being: CLzma2EncoderProperties has the same data members, but there are different limitations. CLzma2Result has only a single byte for the properties, not 5.

Look at the function CreateLzma2Props() in https://github.com/JohnJScott/LZMA2Simple/blob/master/Eternal.LZMA2SimpleTest/OriginalComparisonTests.cpp to see the removed encoder settings.

Unit test priorities:

  • 0 - Generate various lookup tables
  • 11 - Various C++ Lzma1 compress/decompress validation
  • 12 - Various C++ Lzma2 compress/decompress validation
  • 21 - Various C# Lzma1 compress/decompress validation
  • 22 - Various C# Lzma2 compress/decompress validation
  • 50 - Ensures the refactored C++ compressed data matches the compressed data from the vanilla 7-Zip SDK
  • 60 - Ensures the C# compressed data matches the C++ compressed data.

The OriginalSevenZip project references the original SDK; it's just a compile wrapper. Given this readme resides at ~/Eternal/Eternal.LZMA2Simple/ Put the 7-Zip SDK at ~/ThirdParty/7-Zip/lzma2501/ to make everything work seamlessly.

Performance: The refactored C++ decompress seems to be about 50% slower than the reference version. This is unacceptable and I'm working on it, but I found that 60% of the time is in malloc or free and I need to rethink my testing.

Run the test TestCompareExhaustiveBC3 to get test output in a CSV format.

Changes 12th November 2026

Updated to net11. Updated packages. Fixed off by one bug in MemoryWriter.

Changes 8th November 2026

Added NuGet Native package

Changes 2nd September 2026

Updated packages and metadata.

Changes 24th July 2026

Added SBOM. Updated packages.

Changes 21st April 2026

Initial release

Notes

Full Doxygen documentation at https://eternaldevelopments.com/docs

This utility appeals to the most niche aspects of development, but if you feel like making a donation, please send DOGE to DFbEt36Qg2s2CVAdk5hZgRJfH8p1g6tW9i or buy a #programmerlife t-shirt

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net11.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
1.0.6 47 11/15/2026
1.0.5 57 11/12/2026
1.0.4 161 9/2/2026
1.0.3 142 7/24/2026
1.0.2 152 6/20/2026
1.0.1 143 5/17/2026
1.0.0 148 4/22/2026