Please note that this project is no longer actively maintained or supported. While I appreciate your interest in this project, I can no longer provide updates and bug fixes. Thank you for your understanding and support.
Note As an alternative, I highly recommend that you consider migrating to the MessagePack-CSharp, which provides an extended set of features and is actively maintained by a dedicated team of developers.
Binary serializer built with low latency network communication in mind.
https://www.nuget.org/packages/BitSerializer/
- Easy to use
- Lightweight
- Fast serialization and deserialization (see Performance section)
- Supports nested schema types
- No external compiler required
- Classes/Structs as schema
- Included sample projects
The best way to learn how to use BitSerializer is to take a look at the provided sample projects.
Define a schema class/struct containing fields you want to serialize.
publicclassDataPacket{// Fields or properties you want to serializepublicintId{get;set;}publicbyte[]Payload{get;set;}// Remember to always include a parameterless constructor, otherwise the deserializer won't be able// to create a new instance of the class.publicDataPacket(){}publicDataPacket(intid,byte[]payload){Id=id;Payload=payload;}}Create an instance of the schema class and pass it to the BinarySerializer.Serialize method.
DataPacketpacket=newDataPacket(id:1,payload:newbyte[]{0x1,0x2,0x3});byte[]bytes=BinarySerializer.Serialize(packet);Pass bytes returned by the BinarySerializer.Serialize to the BinarySerializer.Deserialize<T> method specifying the type of the schema class.
DataPacketpacket=BinarySerializer.Deserialize<DataPacket>(bytes);