Skip to content

karlseguin/Metsys.Little

Repository files navigation

Metsys.Little

Metsys.Little is a lightweight .NET binary serializer with a focus on compactness and speed. Given the following object:

var user = new User { Id = 433, Name = "Goku" Enabled = true, Initial = null, Description = null, };

Metsys.Little will serialize this to a 13 bytes. The built-in BinaryFormatter will take 400 bytes. The object created in the IntegrationTests.NestedTypesWithCollectionOfObjects method serializes to 74 bytes – the BinaryFormatter is over 900.

This is achieved without any cpu-intensive compression or other fancy tricks.

Limitations

Metsys.Little supports built-in value types (int/short/long/float/double/decimal/byte/char/enums/datetime/guids) and strings. It also supports a number of IEnumerable’s – with the main exception being Dictionary types (non-generic types aren’t likely to work either).

The type must have a default constructor – it can be private.

Usage

Use the Serializer.Serialize method to turn your object into a byte array:
var data = Serializer.Serialize(new User{...});

Use the Deserializer.Deserialize method to turn your byte array (or stream) back into your object:
var user = Deserializer.Deserialize(data);

Metsys.Little does not (currently) support versioning. If your object changes (add/remove properties) previously serialized data will not be able to be deserialized. Metsys.Little is suited for short-lived data (shopping carts, session) or where versioning is handled at the application layer.

If you like Little, you may also want to check out Protobuff – there are a number of quality C# implementations. Protobuf supports versioning, can be smaller, and some implementations are faster.

About

A fast and compact binary [de]serializer for .NET

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages