Skip to content

Consider extending JsonIncludeAttribute and JsonConstructorAttribute support to internal and private members. #87431

Closed
@eiriktsarpalis

Description

@eiriktsarpalis

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:

  1. Extend JsonConstructorAttribute support to internal constructors. (Json serializer code generator doesn't support internal constructors #77016)
  2. Extend JsonIncludeAttribute support to internal properties and fields.
  3. [Optional/TBD] add private member support for both attributes (only possible with the reflection serializer/needs .NET 8 runtime features).

Metadata

Metadata

Labels

area-System.Text.JsonenhancementProduct code improvement that does NOT require public API changes/additionssource-generatorIndicates an issue with a source generator feature

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions