-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Document known issues and semantic differences between the various JSON-serialization programming models #26040
Comments
This is covered by this section: https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-source-generation?pivots=dotnet-6-0#serialization-optimization-mode
Accessible surface areaThe source generator can only access ConstructorsIn both src-gen & reflection mode, only public ctors can be used for deserialization. PropertiesIn both src-gen & reflection mode, only public properties can be used for deserialization. However, in reflection mode, FieldsOnly -- Note that there's a tracking issue for extending non-public support in STJ, but src-gen restrictions would still apply - dotnet/runtime#31511. Support for deserializing init-only propertiesInit-only prop deserialization is supported in the reflection serializer, but not source-gen. This is because the metadata-only mode required for deserialization cannot express the required initialization statically in source, while the reflection serializer can use runtime-reflection to set the properties after construction. With a new generation mode where read logic is generated using the reader directly (fast-path deserialization), the required static initialization can be provided.
|
From @krwq in dotnet/runtime#60178:
|
Help us make content visible
Describe the new article
With the new JSON source generator, we now have a few programming models for JSON (de)serialization:
We should describe any feature and semantic differences between them, e.g. source-gen lack of support for init-only property deserialization (dotnet/runtime#58770), lack of support for private members.
We should also describe feature differences in fast-path mode vs metadata serialization mode - dotnet/runtime#51945 (comment).
cc @eiriktsarpalis, @steveharter, @tdykstra , @eerhardt, @ericstj, @jeffhandley, @jkotas, @stephentoub
The text was updated successfully, but these errors were encountered: