You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, awesome package you have here. However, I have found a potential bug when you are serializing a base type while enabling discriminators. I have added a failing test below.
When you serialize a base type with discriminators enabled, it'll be serialized with the base type as the discriminator value. See also provided test case.
Actual behavior
I get the following error:
System.Collections.Generic.KeyNotFoundException: The given key '(...).Animal' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at JsonSubTypes.JsonSubtypesConverter.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:line 652
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:line 691
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:line 80
(...)
The text was updated successfully, but these errors were encountered:
I don't agree with the expectation that unregistered base class should serialize their class name because the "discriminator's value" may be numeric or have a specific naming convention (with specific prefix/suffix or another)
When using JsonSubtypesConverterBuilder all sub types should be registered:
Hello, awesome package you have here. However, I have found a potential bug when you are serializing a base type while enabling discriminators. I have added a failing test below.
Expected behavior
When you serialize a base type with discriminators enabled, it'll be serialized with the base type as the discriminator value. See also provided test case.
Actual behavior
I get the following error:
The text was updated successfully, but these errors were encountered: