Snowberry.IO 2.1.0

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

// Install Snowberry.IO as a Cake Tool
#tool nuget:?package=Snowberry.IO&version=2.1.0                

License NuGet Version

A binary reader and writer that supports different endian types.

Usage

Features

  • Reader

    • Read different endian types for supported data types.
    • Custom analyzer that can be used to analyze bytes when they were filled into a buffer.
    • Read zero terminated strings (ReadCString).
    • Read sized zero terminated strings (ReadSizedCString).
    • Read size prefixed strings (ReadString).
    • Read lines (ReadLine).
    • Read custom Sha1 type.
    • Read padding.
    • Enable custom region view.
  • Writer

    • Write different endian types for supported data types.
    • Write zero terminated strings (WriteCString).
    • Write sized zero terminated string (WriteSizedCString).
    • Write custom Sha1 type.
    • Write padding.
    • Write lines (WriteLine).
    • Write size prefixed strings.
  • Custom Sha1 type based on SHA-1.

Most used types

Name Description
Reader
BaseEndianReader The abstract base type that implements the IEndianReader interface.
EndianStreamReader Used for reading from streams, inherits the BaseEndianReader type.
Writer
EndianStreamWriter Used for writing into streams, inherits the BinaryWriter type and implements the IEndianWriter interface.

Reader and writer

var stream = new MemoryStream();
using var writer = new EndianStreamWriter(stream, keepStreamOpen: true);

writer.Write(10,  EndianType.BIG)
      .Write(20L, EndianType.BIG)
      .Write(30F, EndianType.BIG)
      .Write(40u, EndianType.BIG)
      .Write(50d, EndianType.BIG);
      
writer.BaseStream.Position = 0;

using var reader = new EndianStreamReader(stream);

_ = reader.ReadInt32(EndianType.BIG);
_ = reader.ReadLong(EndianType.BIG);
_ = reader.ReadFloat(EndianType.BIG);
_ = reader.ReadUInt32(EndianType.BIG);
_ = reader.ReadDouble(EndianType.BIG);

Custom analyzer

The Analyzer abstract type can be inherited and used to monitor each buffer fill operation.

This is useful if a binary file is or has encrypted content.

Endian converter

The BinaryEndianConverter type can be used to convert data in a Span<byte> to all supported data types and also accepts an offset.

var buffer = new byte[] { ... };
int offset = ...;
var endianType = EndianType.BIG;

_ = BinaryEndianConverter.ToLong(buffer, endianType);
_ = BinaryEndianConverter.ToLong(buffer, offset, endianType);

Supported data types

Type Endian type(s)
Int8 -
UInt8 -
Int16 Little, Big
UInt16 Little, Big
Int32 Little, Big
UInt32 Little, Big
Int64 Little, Big
UInt64 Little, Big
Float Little, Big
Double Little, Big
Guid Little, Big
Sha1 Little
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 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. 
.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 Snowberry.IO:

Package Downloads
Snowberry.IO.SingleFile

A library for reading and modifying bundles from single-file published .NET applications.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 96 11/14/2024
2.0.0 1,521 5/16/2024
1.0.0.10 431 11/14/2023 1.0.0.10 is deprecated because it is no longer maintained.