rikimaru0345 / Ceras

Universal binary serializer for a wide variety of scenarios https://discord.gg/FGaCX4c
MIT License
480 stars 53 forks source link
binary c-sharp csharp database dotnet dotnet-core formatter msgpack net network networking persistent-storage protocol serialisation serialization serialize-objects serializer

Ceras

AppVeyor Test Results Discord NuGet Release

Ceras is a binary serializer. It converts any object into a byte[] and back. It goes above and beyond in terms of features, speed, and comfort. Supports reference loops, large/complicated inheritance chains, splitting objects into parts, ...

Quick start

class Person { public string Name; public int Age; }
var p = new Person { Name = "riki", Age = 5 };

var ceras = new CerasSerializer();

var bytes = ceras.Serialize(p);
  1. >> Many more examples in the code tutorial
  2. >> Detailed guides for specific scenarios on my blog
  3. >> Read 'Optimization & Usage Pitfalls'

Features

Performance benchmarks

Ceras generally ranks at the top end of the performance spectrum, together with NetSerializer and MessagePack-CSharp. To get an idea of how Ceras performs here are the preliminary benchmark results. The resulting binary size is about the same as MessagePack-CSharp.

Single object performance benchmark

The shown results are obtained from this code and I encourage you to not only try it yourself, but to also provide feedback about scenarios you had good and bad results with.

Don't forget to tune the settings in SerializerConfig for your specific situation. Using Ceras to read/write network packets might require different settings than, lets say, saving a settings-object to a file, or persisting items/spells/monsters in a game, or ...

The project is still heavily work-in-progress, meaning that over time more optimizations will get implemented (your feedback is important here!).

What can this be used for?

Example usages

The primary goal is to make an universal serializer that can be used in every situation. Personally my primary intentions were easy object persistance and network communication. I've added many features over time and whenever someone can think of a good scenario that should be supported as well I'll make it happen.

Examples:

When should I not use this?

Support

>> FAQ

>> Development Blog