-
Notifications
You must be signed in to change notification settings - Fork 96
Open
Description
Dotvvm version 5.0 preview 7.
NET 9.0
In VM, I have an workflow graph represented something like this:
[JsonConverter(typeof(WorkflowGraphJsonConverter))]
public class WorkflowGraph : BidirectionalGraph<GraphNode, GraphEdge<GraphNode, string>>
{
Where GraphNode has x descendants:
[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
[JsonDerivedType(typeof(GraphNode), nameof(GraphNode))]
[JsonDerivedType(typeof(ConditionGraphNode), nameof(ConditionGraphNode))]
[JsonDerivedType(typeof(RetryHandlerNode), nameof(RetryHandlerNode))]
[JsonDerivedType(typeof(DelayStep), nameof(DelayStep))]
[JsonDerivedType(typeof(LoopIteratorNode), nameof(LoopIteratorNode))]
.....
public class GraphNode
{
Write method on converter using simple wrapper class where in Nodes list are instances of GraphNode :
public override void Write(Utf8JsonWriter writer, WorkflowGraph value, JsonSerializerOptions options)
{
var wrapper = new WorkflowGraphData
{
Nodes = value.Vertices.ToList(),
Edges = value.Edges.Select(e => new GraphEdgeData
{
Source = e.Source.Name,
Target = e.Target.Name,
Tag = e.Tag,
Condition = e.Condition
}).ToList()
};
JsonSerializer.Serialize(writer, wrapper, options);
}
If I verify the functionality of the converter with a test, everything is serialized correctly.
Dotvvm also uses the converter, verified by breakpoint.
But on client side I get only properties from base class GraphNode:
{
"$type": "RX2xRc+exIlXuIVJ",
"Name": "start",
"Type": "GraphNode"
},
{
"$type": "RX2xRc+exIlXuIVJ",
"Name": "copy-files-to-s3:01",
"Type": "CopyFilesToS3Node"
},
{
"$type": "RX2xRc+exIlXuIVJ",
"Name": "register-retention-target:02",
"Type": "RegisterRetentionTargetStep"
},
{
"$type": "RX2xRc+exIlXuIVJ",
"Name": "copy-files-to-s3:01:retry",
"Type": "RetryHandlerNode"
}
Is polymorphic serialization supported, or is JsonSerializer only used internally?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels