-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[release/8.0] Throw when applying JsonObjectHandling.Populate
to types with parameterized constructors.
#92947
Conversation
… on types with parameterized constructors.
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsBackport of #92937 to release/8.0 /cc @eiriktsarpalis Customer ImpactTestingRiskIMPORTANT: If this backport is for a servicing release, please verify that:
|
@eiriktsarpalis - is this something we'd want to change later to add parameterized constructor support? (e.g. 9.0, servicing, never?) |
We are leaving it in the backlog (#92877) as something we will consider adding support for in .NET 9+. We would not bring it for servicing though. |
Approved by Tactics via email. |
Backport of #92937 to release/8.0
/cc @eiriktsarpalis
Customer Impact
We received a customer report that the newly added
JsonObjectCreationHandling
feature (aka "populate read-only members") does not behave as expected when applied to types that deserialize using parameterized constructors. On closer inspection it turned out fixing the feature for that particular use case would necessitate substantial refactoring of async serialization code, something that is too risky/time consuming to do at this stage. Instead, this PR adds checks and throws an explicit exception when users attempt to use the feature on types with parameterized constructors.Testing
Added unit testing validating the throwing behavior.
Risk
Low. Adds additional validation to product code to block the unsupported scenario.