Closed yume-chan closed 9 years ago
Fixed
My class overrode Equals()
method so a ContentA
and a ContentB
will be equivalent if their have same data.
[JsonConverter(typeof(ListConverter))]
class ContentA {
public ContentB B { get; set; }
public override bool Equals(object other) {
// ......
if (other is ContentB)
return this.B.Equals(other);
// ......
}
But JSON.NET thinks it's a self reference because JsonSerializerInternalWriter._serializeStack
already contained a ContentA
which is equals to the converted ContentB
.
Maybe JsonSerializerInternalWriter.SerializeConvertable()
should not add the source object to _serializeStack
(Now it doesn't add the converted object, is it another bug)? Or maybe JsonSerializerInternalWriter.CheckForCircularReference()
should check equability by ReferenceEquals()
?
In fact after this fix my code can never finish, I'm trying to build a minimal code example. EDIT: sorry, my code has other true loop references.
I'm using 7.0.1b3 on .NET and 6.0.8 on Portable Library.
If I didn't use converter JSON.NET will create correct references, if I didn't include type names JSON.NET can deserialize it without problem, but if I combine them the problem will occur.