System.Text.Json Source Generators
The JSON serialization can be optimized using source generators.
I understand that I have to write a context for the given class I wish to serialize.
And I'd specify the given context when serializing the class instance.
What I do not understand is how I would pass the context for other classes within the serialized class?
E.g.
Is the context of the
CanvasSettings
including data for the its property members?
How can I utilize source generators when working with polymorphic types?
E.g., IAnimal
, Dog : IAnimal
, Cat : IAnimal
.
Do I write a context for the interface? How would the context cover all the members of the derived classes?1 Reply
you should not be making a new context for each class, to be clear
you should just make one context for your library and put all your classes on it