Avalanche.Protobuf
Avalanche.Protobuf is class library for protobuf3 datatypes and accessors.
// Create IService
IServiceProvider service = Services.Create(Avalanche.Protobuf.Module.Instance);
// Get serializer
var serializer = service.GetRequiredService<Func<MyClass, byte[]>>();
// Create object
var obj = new MyClass { Id = 100 };
// Serialize object
byte[] data = serializer(obj);
// Print protobuf3 serialization
Console.WriteLine(Hex.PrintFromBytes(data)); // "1064"
// 10 = WireType = VarInt, FieldNumber = 2
// 64 = 100
public sealed class MyClass
{
[DataMember(Order = 2)]
public uint Id;
}
Features:
- Code-first approach
- Class Inheritance
- Referable object serialization
- object as Any type
- Class generics
- One-to-many binding, from binary to others.
Class libraries:
- Avalanche.Protobuf.dll
- Avalanche.Protobuf.Abstractions.dll
Other:
- Interoperability: .NET 7 and upwards