tags:

views:

100

answers:

2

Actually I want to serialize my data using Google's java implementation and then deserialize using C# implementation?
I have chosen portobuf-net as it seems to be more stable (porto# 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 potobuf-net). Or is there any list of methods that are specific to portobuf-net implementation?

A: 

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.

Stephen
All implementations should be wire compatible.
Marc Gravell
@Marc Gravell - Thanks. I found the description that protobuf-net is wire-compatible with Google's format ( http://code.google.com/p/protobuf-net/ ). The mistyped name 'portobuf-net' threw me off, I thought it was a different project. Edited my answer for clarity.
Stephen
+1  A: 

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).

Marc Gravell
I would be generating all the code from .porto file. So it should be portable.
cornerback84
@cornerback84 - FYI, it's "proto" (as in protocol) not "porto". You've made that typo a few times, so I thought it deserved clearing up :)
Stephen