Question

Actually I want to serialize my data using Google's java implementation and then deserialize using C# implementation?
I have chosen protobuf-net as it seems to be more stable (proto# is still v0.9 or I would have gone for it). Before I start working on it I wanted to be sure that I can achieve this (serializing data using java implementation and deserializing it using protobuf-net). Or is there any list of methods that are specific to protobuf-net implementation?

Was it helpful?

Solution

If you want the same API on multiple platforms, Jon Skeet's implementation may be more appropriate to you. The difference is that protobuf-net is designed around common C# development patterns, for example it doesn't demand that you use the generated types (you can use your own, exactly like you can with DataContractSerializer, XmlSerializer, etc) - and it supports some BCL concepts directly.

The two should be 100% compatible on the wire, but here's some API differences:

  • direct support for DateTime, TimeSpan, Guid etc (described by the contracts in bcl.proto in the zip)
  • support for inheritance (mapped as nested data on the wire)
  • support for your own types
  • support for mutable types (rather than the builder/immutable pair)
  • support for serialization callbacks
  • (possibly a few others - do you need a 100% complete list?)

The one you are most likely to notice is inheritance. Simply: don't use this if you are planning to use interop. I have tried to make it very explicit in the intellisense if you are doing something that will use .NET-specific tricks, but if you start from a .proto it won't use these anyway (it should be portable-friendly).

OTHER TIPS

All the google serializations are wire compatible, and although protobuf-net isn't written by Google, it claims to be wire-compatible.

In addition, there is a page of compatible C# APIs linked from Google's documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top