Skip to content
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

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

Closed
Tracked by #77019
eiriktsarpalis opened this issue Jun 12, 2023 · 1 comment · Fixed by #88452
Assignees
Labels
area-System.Text.Json enhancement Product code improvement that does NOT require public API changes/additions source-generator Indicates an issue with a source generator feature
Milestone

Comments

@eiriktsarpalis
Copy link
Member

eiriktsarpalis commented Jun 12, 2023

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).
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jun 12, 2023
@eiriktsarpalis eiriktsarpalis added this to the 8.0.0 milestone Jun 12, 2023
@ghost
Copy link

ghost commented Jun 12, 2023

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

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).
Author: eiriktsarpalis
Assignees: -
Labels:

area-System.Text.Json, untriaged

Milestone: -

@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jun 12, 2023
@eiriktsarpalis eiriktsarpalis added source-generator Indicates an issue with a source generator feature enhancement Product code improvement that does NOT require public API changes/additions labels Jun 12, 2023
@eiriktsarpalis eiriktsarpalis self-assigned this Jun 12, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 5, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jul 7, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Aug 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Json enhancement Product code improvement that does NOT require public API changes/additions source-generator Indicates an issue with a source generator feature
Projects
None yet
1 participant