Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't serialize Diagram using System.Text.Json #94

Closed
Swordancer opened this issue May 2, 2021 · 2 comments
Closed

Can't serialize Diagram using System.Text.Json #94

Swordancer opened this issue May 2, 2021 · 2 comments

Comments

@Swordancer
Copy link

When I try to serialize Diagram I get.

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Serialization and deserialization of 'System.Type' instances are not supported and should be avoided since they can lead to security issues. Path: $.Inputs.Parent.ShapeDefiner.Method.ReturnParameter.Member.DeclaringType.
System.NotSupportedException: Serialization and deserialization of 'System.Type' instances are not supported and should be avoided since they can lead to security issues. Path: $.Inputs.Parent.ShapeDefiner.Method.ReturnParameter.Member.DeclaringType.

All you need to do to reproduce this error is to create empty instance of Diagram inside webassembly project component and then just try to serialize it with System.Text.Json. Is kind of an issue as I want to be able to pass my custom diagram to the server side safely.

@zHaytam
Copy link
Collaborator

zHaytam commented May 2, 2021

Hello,

You will have a lot of issues if you try to serialize the diagram directly, as It contains Types and many loops. Currently, there is still no built-in way to serialize a diagram in the library, I'm still thinking about a good solution and will probably just settle on Json at first as it's the most used.

A possible solution that you can use is to represent the diagram the way your backend needs, for example create anonymous objects for the diagram, the list of nodes and links, and serialize that instead. By doing so, you can choose exactly what to ignore/export. This is what I'm doing in my apps and it's what everyone should do, since serializing the full diagram isn't always the best idea.

@Swordancer
Copy link
Author

Thanks for anwser. This is what Im trying to do right now or maybe I'll just write custom converters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants