I'm looking for advice on serialization in a .net app. The app is a desktop/thick client app and the serialization represents the persisted document format. The requirements for the serializer is
- Must allow serializing fields, not public properties only.
- Must not require parameterless constructors.
- Must handle general object graphs, i.e. not only DAG but shared/bidirectional references.
- Must work with framework classes (e.g. Serialize Dictionaries).
Currently we use the BinaryFormatter which handles all of the above quite well, but size/performance and version tolerance is an issue. We use the [OnDeserialized/ing] attributes to provide compatibility, but it does not allow for large refactorings (say a namespace change) without complex use of surrogates and so on.
An ideal solution would be a drop-in replacement for BinaryFormatter that works with our existing [NonSerialized] annotations etc., but performs better, and produces a format that is smaller and easier to maintain.
I have looked at the different protobuf implementations, and even though it seems possible to serialize general object graphs/enums/structs these days, it does not appear trivial to serialize a complex graph with a lot of framework collection types etc. Also, even if we could make it work with fields rather than properties I understand it would still mean having to add parameterless constructors and protobuf annotations to all classes (The domain is around 1000 classes).
So the questions:
- Are there any "alternative" Binary formatters, that provide a well documented format, perform better?
- Are protocol buffers ever suitable for persisting large general object graphs including framework types?