I suspect this might be a Json.NET issue, but perhaps someone here can shed some light on it.
I'm persisting a large object graph to Raven, and several of the classes are marked with the
[JsonObject(IsReference = true)] attribute, as they are referenced by other objects elsewhere in the hierarchy. These objects get serialized as expected (i.e. a '$id' value is added to one instance, and duplicate instances are replaced with a '$ref' value).
I recently added a new class to the hierarchy, again marked with the same JsonObject attribute, but it's not being "de-duplicated" like the others. Instances of this class within the graph are definitely the exact same object reference, and there is nothing unusual about the new class compared to the others - it has a parameterless ctr, and is being used in the hierarchy in much the same way.
I can get them de-duplicated using the following code:-
documentStore.Conventions.CustomizeJsonSerializer = s =>
{
s.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
};
But this feels a bit extreme, and I wanted to avoid going down this route if possible.
Unfortunately I wasn't able to create a failing test, probably due to the large and complex nature of the object graph. Any thoughts or suggestions? I'm using Raven 2.5.2750 btw.