-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
JSON needs object initializer equivalent APIs #73219
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsRecently C# has added two features which rely on the object initializer syntax:
In the current state JSON reflection APIs can ignore the fact that property is We should:
One way to solve this problem is to treat Relevant issues:
|
The reflection object does allow you to check whether the property is required by looking for |
We might want to address this in combination with #71944. |
Fixed in #83147. Any outstanding work is tracked by the issues linked in the description. |
So it's completed, but still in Future milestone - that's intentional? |
Recently C# has added two features which rely on the object initializer syntax:
required
keywordIn the current state JSON reflection APIs can ignore the fact that property is
init-only
and still set it andrequired
constraint is not enforced. For source-gen on the other hand regular setter code simply won't compile and similarly forrequired
properties constructor will cause compile errors.We should:
One way to solve this problem is to treat
init-only
andrequired
properties the same way as arguments to parametrized constructor, then passing them to parametrized constructor assigns them in the object initializer.Relevant issues:
The text was updated successfully, but these errors were encountered: