-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I'm using .NET 8. When I'm trying to serialise the base type, it's crashing. I hoped it would just convert it to the AttributeText due to the PolyJsonConverter.
This is my class
[PolyJsonConverter("attribute_type")]
[PolyJsonConverter.SubType(typeof(AttributeIdentifier), "pim_catalog_identifier")]
[PolyJsonConverter.SubType(typeof(AttributeText), "pim_catalog_text")]
public class AttributeValueBase
{
[JsonPropertyName("attribute_type")]
public string AttributeType { get; set; }
[JsonIgnore]
public bool IsNew { get; set; }
}
public class AttributeIdentifier : AttributeValueBase
{
[JsonPropertyName("data")]
public string Data { get; set; }
}
public class AttributeText : AttributeValueBase
{
[JsonPropertyName("data")]
public string Data { get; set; }
}When I try to serialize it using the base class it crashes:
try
{
var test = new AttributeValueBase();
test.AttributeType = "pim_catalog_text";
test.IsNew = true;
string json = JsonSerializer.Serialize(test);
}
catch (Exception ex)
{
throw;
}I've noticed it's recusively calling the public override void Write(...) method on PolyJsonConverter<T> class.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels