Monday, September 02, 2013

Protobuf-net: the unofficial manual

Protobuf-net is a fast and versatile .NET library for serialization based on Google's Protocol Buffers. It's one of those libraries that is both widely used and poorly documented, so usage information is scattered across the internet (that said, I want to thank the author for being incredibly responsive to questions on StackOverflow). The majority of official documentation is in GettingStarted, and small amounts of information exist in XML doc-comments in the source code (which will appear automatically in Visual Studio IntelliSense provided that your protobuf-net.dll file has a protobuf-net.xml file beside it.) The doc-comments are rarely more than a vague hint, though, about what something does or means. The author's blog has various info too.

So, I'm consolidating a bunch of random information into this blog post. I've mentioned a bunch of things that I don't know or that I merely inferred. If you know something I don't, leave a comment and I'll incorporate the information into the article.  

Table of contents 
  • Overview 
  • Forms of type serialization 
  • Collection handling 
  • Random facts
  • Serializing without attributes 
  • Data types 
  • Versioning 
  • How references work 
  • Mysteries 
  • Other sources of information 

Protobuf-net is not compatible with the standard .NET serialization system. It can be configured to behave in a fairly similar way, but one should be aware that
  • protobuf-net ignores the [Serializable] attribute
  • protobuf-net does not support custom serialization using ISerializable and a private constructor, and AFAIK it does not offer something very similar.
However, it does offer several approaches to serialization on a type-by-type basis (see next section).

Read more: Codeproject
QR: Inline image 1