Closed
Description
As shipped the JsonConstructorAttribute
is limited to public constructors only and JsonIncludeAttribute
only works with public properties in which either the getter or setter is non-public but not with fields. These annotations can only be scoped to individual members and we've received customer feedback indicating confusion whenever the serializer is not honoring an explicit instruction made by the user.
This issue tracks extending support for these attributes so that user intentions are always honored, where possible. More specifically, it proposes that we:
- Extend
JsonConstructorAttribute
support to internal constructors. (Json serializer code generator doesn't support internal constructors #77016) - Extend
JsonIncludeAttribute
support to internal properties and fields. - [Optional/TBD] add private member support for both attributes (only possible with the reflection serializer/needs .NET 8 runtime features).