Bny.RawBytes 1.0.1

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

// Install Bny.RawBytes as a Cake Tool
#tool nuget:?package=Bny.RawBytes&version=1.0.1

Bny.RawBytes

C# library for converting from and to bytes. Without the boring repetition.

In this repository

  • Bny.RawBytes: the library
  • Bny.RawBytes.Tester: unit tests

How to use

Code

using Bny.RawBytes;

var arr = new byte[] { 0, 2, 0, 0, 0, 2, 0, 0 };

// convert bytes (arr) to BinaryTest, the default byte order will be big-endian
Console.WriteLine(Bytes.To<BinaryTest>(arr, Endianness.Big));

[BinaryObject] // mark this as binary object
class BinaryTest
{
    // properties and fields with the BinaryMember attribute
    // will be readed in the same order in which they are written in code
    // or you can specify your own order with the Order property

    // Width will be readed first and always in little endian byte order
    [BinaryMember(endianness: Endianness.Little)]
    public int Width { get; init; }

    // Second will be readed height in the default byte order (big-endian in this case)
    [BinaryMember]
    public int Height { get; init; }
    
    // members without the attribute are ignored
    public int Size => Width * Height;

    public override string ToString() => $"[{Size}({Width} * {Height})]";
}

Output

[67108864(512 * 131072)]

How to get it

Product Compatible and additional computed target framework versions.
.NET 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1 157 12/24/2022
1.0.0 143 12/24/2022