-
Notifications
You must be signed in to change notification settings - Fork 127
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
[feature/dataflow] Support DynamicallyAccessedMemberKinds.RecursiveProperties
#1087
Comments
Can we have someone who understand System.Text.Json really well look at whether they can make things work with just a capability like this? We spent a lot of time trying to make reflection-based serialization in .NET Native "just work", to no avail - serializers pretty much never operate in these naive ways, and most then have a bunch of pluggability that makes any analysis impossible. For this example:
|
cc @steveharter @layomia @jozkee - the owners of System.Text.Json.
I'm sure it will take other capabilities as well, for example
I assume we will also need a |
For serializing and deserializing types passed to JsonSerializer, we'll need the following
cc @steveharter, @jozkee PTAL for any gaps. |
Thanks @layomia. Translating this to Linker-terms in which we would be able to avoid special-casing System.Text.Json within the linker (which is really preferable because we don't want to send a message that there's only one linker-friendly way to do serialization in .NET):
Polymorphic deserialization will probably bring new challenges (especially if it's done through something like a |
/cc @vitek-karas |
To avoid security-related concerns we do need a KnownTypes attribute and\or a mechanism to add known types at run-time. |
FWIW another viewpoint for some users is that they may want the linker to remove unused properties. However, they likely will want the JSON to still round-trip which they can do via an extension property by using the |
If we were to do the "Recursive" annotations, it might be worth considering arrays - and "unfortunately" generics as well.
|
At the moment we're not planning on doing this -- the side-effects/viralness of this annotation is too broad compared to alternatives like source generators. We can reconsider if we find a blocking scenario and can come up with an acceptable design |
For (de)serialization cases, like in
System.Text.Json
, we need a way to tell the linker to keep the properties of typeT
, and also the properties of any types referenced byT
's properties recursively.Take the example in https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-how-to:
Note that the properties of
HighLowTemps
need to be preserved even though I didn't directly passHighLowTemps
intoJsonSerializer.Deserialize
. Also note that when walking the properties recursively, we need to handle generic collections:Dictionary<string, HighLowTemps>
.The text was updated successfully, but these errors were encountered: