IonKiwi.lz4.managed 1.0.7

dotnet add package IonKiwi.lz4.managed --version 1.0.7
NuGet\Install-Package IonKiwi.lz4.managed -Version 1.0.7
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="IonKiwi.lz4.managed" Version="1.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IonKiwi.lz4.managed --version 1.0.7
#r "nuget: IonKiwi.lz4.managed, 1.0.7"
#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.
// Install IonKiwi.lz4.managed as a Cake Addin
#addin nuget:?package=IonKiwi.lz4.managed&version=1.0.7

// Install IonKiwi.lz4.managed as a Cake Tool
#tool nuget:?package=IonKiwi.lz4.managed&version=1.0.7

LZ4 for .NET (original C sources translated to C#)

LZ4 has been written by Yann Collet and the original sources can be found on https://github.com/lz4/lz4
This project contains the translated C# sources

How to use

non-streaming

Non streaming version, works with managed byte arrays, uses the LZ4 Framing Format (v1.6.2).
The compressed data that this stream creates is readable by the lz4 command line tools.

The Compress function has additional parameters to control the result.

  • blockMode: Linked or Independent blocks
  • blockSize: 64KB / 256KB / 1MB / 4MB
  • checksumMode: None / Content / Block
  • maxFrameSize: optional maximum frame size
  • highCompression: use lz4hc mode

Example:

  // compress data
  byte[] dataToCompress = ...
  byte[] compressedData = LZ4Utility.Compress(dataToCompress);
  // decompress data
  byte[] decompressedData = LZ4Utility.Decompress(compressedData);

streaming

Streaming version, uses the LZ4 Framing Format (v1.6.2).
The compressed data that this stream creates is readable by the lz4 command line tools.

Example:

  // compress data [with content checksum]
  using (LZ4Stream stream = LZ4Stream.CreateCompressor(innerStream, LZ4StreamMode.Write, LZ4FrameBlockMode.Linked, LZ4FrameBlockSize.Max64KB, LZ4FrameChecksumMode.Content)) {
    // write uncompressed data to the lz4 stream
	// the stream will compress the data and write it to the innerStream
	stream.Write(buffer, 0, buffer.Length);	
  }
  
  // compress data [with block and content checksum, start a new frame after 100 data blocks]
  // note: the lz4 command line tools do NOT support block checksums currently
  using (LZ4Stream stream = LZ4Stream.CreateCompressor(innerStream, LZ4StreamMode.Write, LZ4FrameBlockMode.Linked, LZ4FrameBlockSize.Max64KB, LZ4FrameChecksumMode.Block | LZ4FrameChecksumMode.Content, 100)) {
    // write uncompressed data to the lz4 stream
	// the stream will compress the data and write it to the innerStream
	stream.Write(buffer, 0, buffer.Length);	
  }
  
  // decompress data (in read mode)
  using (LZ4Stream stream = LZ4Stream.CreateDecompressor(innerStream, LZ4StreamMode.Read)) {
    // the lz4 stream will read the compressed data from the innerStream
    // and return the uncompressed data in 'buffer'
	int bytesRead = stream.Read(buffer, 0, buffer.Length);
  }
  
  // decompress data (in write mode)
  using (LZ4Stream stream = LZ4Stream.CreateDecompressor(innerStream, LZ4StreamMode.Write)) {
    // the lz4 stream will decompress the data from 'buffer'
	// and write the uncompressed data to the 'innerStream'
	stream.Write(buffer, 0, buffer.Length);
  }
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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 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. 
.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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on IonKiwi.lz4.managed:

Package Downloads
dbx-sql-csharp

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.7 5,948 9/2/2022
1.0.6 397 8/31/2022
1.0.5 3,628 12/28/2021
1.0.4 7,131 1/10/2021
1.0.3 6,262 6/28/2020
1.0.2 4,328 11/2/2019
1.0.1 485 10/22/2019
1.0.0 580 10/21/2019

v1.0.6
translated lz4 1.9.4

for .net 6 use intrinsics
- BitOperations.TrailingZeroCount
- BitOperations.RotateLeft
- BinaryPrimitives.ReverseEndianness

v1.0.7
- handle empty blocks
- remove System.Runtime.CompilerServices.Unsafe dependency from .net6 target