(no title)
Mertax
|
2 years ago
How do serialization libraries, like Newtonsoft JSON.net, work on platforms like iOS/Blazor/Unity that use AOT? Doesn’t seem like anything special has to be done other than reference the Nuget package and it’s just working?
dellamonica|2 years ago
This does not address pre-existing packages obviously. To make them work with AOT you might need to include an XML file (rd.xml) that indicates all the types that could be dynamically generated in your code. It is quite brittle and AFAIK everything might work until you get a runtime failure if something you did not include ends up being constructed.
GordonS|2 years ago
I've stopped using AOT, as IMO it's not (currently) suitable for complex, real-world apps - unless you are prepared for a lot of testing and pain.
matthew-wegner|2 years ago
For schema serialization on known types, there are codegen tools (i.e. moc for MessagePack): https://github.com/neuecc/MessagePack-CSharp
MessagePack is migrating to Rosalyn code generators, so basically invisible codegen. Cysharp's newer serialization library, MessagePack, already uses this: https://github.com/Cysharp/MemoryPack
Nathanba|2 years ago
ledgerdev|2 years ago
kryptiskt|2 years ago
With a newish .NET they don't need reflection for AOT code, as JSON libraries can use source generators instead.