ByteSerialization 0.0.1-alpha.2
See the version list below for details.
dotnet add package ByteSerialization --version 0.0.1-alpha.2
NuGet\Install-Package ByteSerialization -Version 0.0.1-alpha.2
<PackageReference Include="ByteSerialization" Version="0.0.1-alpha.2" />
paket add ByteSerialization --version 0.0.1-alpha.2
#r "nuget: ByteSerialization, 0.0.1-alpha.2"
// Install ByteSerialization as a Cake Addin #addin nuget:?package=ByteSerialization&version=0.0.1-alpha.2&prerelease // Install ByteSerialization as a Cake Tool #tool nuget:?package=ByteSerialization&version=0.0.1-alpha.2&prerelease
ByteSerialization
A declarative serialization library designed for bit-perfect control over binary representation. You can define C# classes like C structs by assigning attributes to classes and properties. Inspired by BinarySerializer by Jeff Haynes.
This library was created from the ground up to support features like references/pointers.
Notably, this libary is used by swe1r-assets.
Example
Consider the following classes:
public class Manufacturer
{
[Order(0)]
public byte NameLength { get; set; }
[Order(1), Length(nameof(NameLength))]
public char[] Name { get; set; }
}
public class Car
{
[Order(0)]
public byte NameLength { get; set; }
[Order(1), Length(nameof(NameLength))]
public char[] Name { get; set; }
[Order(2), Reference]
public Manufacturer Manufacturer { get; set; }
}
Create an object graph like this:
var mf = new Manufacturer() { NameLength = 2, Name = "MF".ToArray() };
var car = new Car() { NameLength = 4, Name = "Car1".ToArray(), Manufacturer = mf };
using (var ms = new MemoryStream())
{
new ByteSerializer().Serialize(ms, car, Endianness.BigEndian);
File.WriteAllBytes("car.bin", ms.ToArray());
}
That gives you the following binary output:
$ xxd car.bin
00000000: 0443 6172 3100 0000 0902 4d46 .Car1.....MF
Bytes | Property | Value |
---|---|---|
04 | car.NameLength | 4 |
43 61 72 31 | car.Name | "Car1" in ASCII |
00 00 00 09 | car.Manufacturer | (pointer to mf) |
02 | mf.NameLength | 2 |
4d 46 | mf.Name | "MF" in ASCII |
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ByteSerialization:
Package | Downloads |
---|---|
SWE1R.Assets.Blocks
A library for handling game assets of Star Wars Episode 1 Racer. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.1-alpha.10 | 48 | 7/12/2024 |
0.0.1-alpha.9 | 83 | 6/21/2024 |
0.0.1-alpha.8 | 67 | 6/20/2024 |
0.0.1-alpha.7 | 58 | 6/17/2024 |
0.0.1-alpha.6 | 55 | 6/17/2024 |
0.0.1-alpha.5 | 62 | 6/4/2024 |
0.0.1-alpha.4 | 52 | 6/4/2024 |
0.0.1-alpha.3 | 50 | 6/4/2024 |
0.0.1-alpha.2 | 65 | 5/31/2024 |
0.0.1-alpha.1 | 54 | 5/30/2024 |
0.0.1-alpha.0 | 59 | 5/29/2024 |