views:

29

answers:

1

I'm using Protobuf-net. Suppose I have a list of Gizmo objects serialized and that each gizmo object reference a Gazoo object. The Gazoo object might be the same object referred by several Gizmo objects.

How would deserialization work in this situation?

Would I get more than one copies of Gazoos for the same referred one in the gizmo objects?

What I would expect would be one copy of Gazoo for all the duplicates in the serialized data.

+2  A: 

The wire-format defined by google is a tree serializer, not a graph serializer, so object-references are not preserved. However, once I get "v2" shipped, I have some nefarious plans to hack object-reference/graph support into the model - essentially by (in that mode) including additional object-id data. This will make it somewhat tricky to use in interop scenarios, however - so ideally only good for protobuf-net <===> protobuf-net.

But nothing today - you'll get multiple copies, or if you get a circular reference it should explode.

Marc Gravell
As always, nice answer! Thank you.
Stecy