At the moment, there are two proto buf libraries for .NET:
http://code.google.com/p/protobuf-csharp-port/ With Jon Skeet as the owner http://code.google.com/p/protobuf-net/ with Marc Gravell as the owner
What is the difference between the two? Are both coded to the same spec as the Google spec? Are there any differences?
The reason I ask is that currently we have proto buf interop between services that use the Java and potentially C++ libraries and want to make sure we avoid any problems or edge cases.
Jon's version is largely a port of the Java version, so has a very similar API and design approach. It is also AFAIK entirely contract-first, i.e. from .proto.
My version comes at it more from a .NET perspective, looking at what is common in .NET serializers - so mutable objects, retrofit to existing types, code-first (although it can still do code-gen from a .proto if you want), etc. It can even infer data from the attributes used by XmlSerializer
and DataContractSerializer
to work side-by-side with existing code, and can plug into both remoting (via ISerializable
) and WCF (via attributes or configuration). So it is deeply rooted in the .NET ecosystem. I also include inheritance support (since that is so common in the other .NET serializers), but this is a bit fiddly to map to other platforms since it has no direct representation in .proto.
The binary data should be identical; that is largely the point of the format ;p It is largely a choice of which API might be more appropriate to you.
For your needs, working side-by-side with C++ and Java code in the same system, and with existing .proto definitions, I suggest Jon's version may be the most appropriate option for you.
If, however, you are doing .NET only, or are doing .NET with interop with external code (i.e. you don't care what language the "other side" uses, since you only have to worry about your own code), then IMO protobuf-net can be a pretty pain free way to consume the data; especially if you have an existing system that you now find you want to serialize (or: serialize faster / smaller).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With