Migrant – open source serialization library


It happens to everyone: you start using a library, find it lacking some features, start fixing it, committing opatches, and then end up rewriting it because the whole premise it based on does not suit your needs.

So it happened with us and serialization in C#, for which we originally used protobuf-net which employs the protocol buffer serialization format by Google.

Serialization is a tricky problem, especially when performance matters for your application. If you go for feature completeness, you compromise speed, but too much focus on speed makes you unable to serialize more complex objects.

We did, however, see room for improvement in both, so we set out to wirte our own library; thus Migrant was born. For now, it is hosted on our github account, but will get a dedicated page when time permits.

A few notes about the library: though it originally used reflection, we decided to abandon it in favour of a more efficient method (though we provide the option to switch between the two). Serializing with the new method is now complete, while deserializing still needs some work.

As far as speed is concerned, preliminary benchmarks are very promising. Care is taken to test the framework thoroughly (also across the two (de)serialization methods) so that things don’t get messed up as the library develops.

A recent feature is the possibility to serialize C# delegates. We will be aiming to increase the performance of this feature, but it works well as is.

Another feature we think quite interesting that we are aiming to get soon is what we call version-tolerant serialization. It often happens that in developing frameworks and programs classes are changed as time passes, and objects serialized by one version cannot be restored by another due to this incompatibility. There are many scenarions, however, when this should be perfectly possible, e.g. when the number of fields is reduced or the new fields have perfectly acceptable default values. In those situations Migrant will allow you to deserialize such a legacy object, perhaps issuing some warnings that this was done.