Open BreyerW opened 4 years ago
Currently implementing the interface is the only way. But implementing an alternative as you described should be pretty easy:
IReferenceResolver
interface that gets stored in the SerializerConfig.All of that could be implemented such that it would still be compatible with the old code. Even better: Right now the external "ID" of an object is locked to being an int, but it doesn't have to be that way. In fact, we could make it so the reference resolver has full control over whats written. That way the user has the option to save space (by writing a VarInt), or go the "easy way" (by writing a normal fixed 32bit int, just like is being done right now), or use some entirely different identifier (like a string or something)...
Currently im using json serializer (Json.net more specifically) but im investigating adding binary serializer as well for efficiency and when readability is not required.
I saw that you support external references which i consider to be very useful in my project but this feature require implementing interface on serialized object which is off-table.
So my question is are there alternatives to this interface that allow same or similar effect without requiring modifying serialized object?
If not i would like to request something akin to
ReferenceResolver
in Json.net. (basically abstract class that intercepts reference indentifiers when deserializing and produces them when serializing)