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 woul开发者_JAVA技巧d expect would be one copy of Gazoo for all the duplicates in the serialized data.
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.
As an update: this is now available in protobuf-net v2, but as an implementation-specific feature outside of the code spec.
精彩评论