.NET wrapper for the Zstandard (zstd) compression native library in Windows, Linux, and macOS. Multithread compression is enabled. Supports x64 and arm64 only, but can easily add x86 and arm support
$ dotnet add package zstd.nativewrapperdotnet wrapper for zstd using interop.
zstd has three header files: zstd.h, zstd_errors.h and zdict.h
I tanslated the first two header files into C# in an almost line-by-line manner. TODO: zdict.h is not translated yet.
Also the offical souce code gives some examples like streaming_compression.c and streaming_decompression.c, which are good references to implement the corresponding C# logic.
Quite easy.
The offical repo release contains only x86 and x64 DLL for windows, and the multi-thread compression is not enabled in these DLLs, so I build the native library files from source in MacOS, Linux and Windows.
But it's quite easy to support, just add the dll/so file to the correct folder inside native folder. NativeLibrary.SetDllImportResolver is used to search for the native lib file. See here for the path lookup logic.