serdedotnet / serde

Serde.NET is a C# port of the popular Serde serialization library for Rust
https://serdedotnet.github.io/
BSD 3-Clause "New" or "Revised" License
154 stars 6 forks source link

Allow struct visitors and use them for compound deserialize #100

Closed agocke closed 1 year ago

agocke commented 1 year ago

Struct visitors are useful (no allocations), but they're tricky, as side-effects may not be preserved when they are copied by the underlying deserializer.

Most importantly, a Native AOT bug (https://github.com/dotnet/runtime/issues/77070) currently causes some static abstract interface calls to fail when they have to be loaded at runtime. Generic specialization can avoid this. By using a struct visitor for some compound calls (dictionaries, enumerables, nullables) the likelihood of hitting this is reduced.