-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Extend JsonIncludeAttribute
and JsonConstructorAttribute
support to internal and private members
#88452
Conversation
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsThe
This PR changes the semantics of both attributes so that they have uniform behavior regardless of accessibility. It assumes that users know what they're doing when annotating a given member and tries to accommodate their request. A notable exception to this rule is the source generator, which will warn/throw a runtime exception if the user tries to include members that are not accessible to the source generated context. Fix #87431
|
Is this an application-runtime exception, or is this a source-generator-runtime exception / application-design-time build error? |
It's both -- a diagnostic warning will be emitted at compile time and an exception will be thrown at run time. |
Test failures are unrelated and tracked by #88453 |
The
JsonInclude
andJsonConstructor
attributes are annotations that can be applied directly to individual members to include them in the JSON contract for a specific type. Historically however these attributes haved either:JsonConstructor
),JsonInclude
on properties requires that either the getter or setter should be public for the non-public counterpart to be accessed) or,JsonInclude
).This PR changes the semantics of both attributes so that they have uniform behavior regardless of accessibility. It assumes that users know what they're doing when annotating a given member and tries to accommodate their request. A notable exception to this rule is the source generator, which will warn/throw a runtime exception if the user tries to include members that are not accessible to the source generated context.
Fix #87431