Reputation: 20727
I'm migrating from the DataContractSerializer in favor of ProtoBuf. One thing that we did previously noticed is that there was a huge impact by using the IsReference =true
of the DataContract with the XML serializer.
I would like to know if there is some reference somewhere about what happens we use the the AsReferenceDefault = true
of the ProtoContract
.
What are the impact on the speed of serialization/deserialization? What are the impacts on what is serialized?
Side question: Is it mandatory that all reference to one object have the IsReference = true, or can I have the main one(the one that really own the object, the place I would expect to have the object serialized) with a IsReference = false and still have only one instance of the same object?
Upvotes: 2
Views: 292
Reputation: 1062865
This flag changes a number of things:
NetObjectProxy
from bcl.proto, for the curious - with field 1
(existing object), or fields 2
and 10
(new objects) set); this will also take a little space per reference (but less space than serializing the object repeatedly)As for how that adds up in reality: it will depend on the scenario, and I'd love to hear your findings.
Re where you need AsReference
: if it isn't specified via AsReferenceDefault
, it will need to be specified on all members where you expect reference tracking to occur. The check is applied at the individual member level, essentially of the form (although this isn't the actual code):
bool asRef = member.AsReferenceSpecified()
? member.AsReference : metaType.AsReferenceDefault;
Upvotes: 1