Fix SafeJsonSerializer
alexyakunin opened this issue · 1 comments
alexyakunin commented
https://github.com/servicetitan/Stl/blob/master/src/Stl/Serialization/SafeJsonNetSerializer.cs
Currently it "solves" two problems:
- Safe denationalization - the Verifier delegate is used on deserialization to tell if the root type is fine to deserialize, and this piece is totally ok to keep
- But overall, it doesn't allow to serialize everything b/c it serializes only the top level type name, so anything nested that needs a type (e.g. Exception) won't deserialize.
#2 works the way it does to actually address the issue w/ WASM: mscorlib is named differently there, so this serializer "fixes" this issue by normalizing its name - and it can do this nicely only b/c there is a single place it needs to fix (root type name).
The right fix, though, would be to fix mscorlib name everywhere during the serialization. Not sure how to do this w/ JSON.NET, but pretty sure it's possible. And if this is done, the serializer would be a complete fit for Stl.Fusion needs:
- Safe deserialization will be used there on "update request" end (Publisher, etc.) - the types should be limited just to a few message types there, the rest should be banned.
- And no-filter deserialization will be used on "update/invalidate receiver" end (i.e. WASM client), where it's totally safe to desalinize everything (it's still a browser-sandboxed .NET).
alexyakunin commented
Just closed this one.