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

Refine JsonIgnoreAttribute semantics when used in conjunction with other attributes. #59364

Open
eiriktsarpalis opened this issue Sep 20, 2021 · 1 comment
Labels
area-System.Text.Json enhancement Product code improvement that does NOT require public API changes/additions Priority:3 Work that is nice to have
Milestone

Comments

@eiriktsarpalis
Copy link
Member

The JsonIgnoreAttribute is a mechanism intended to prevent serialization or deserialization of a given property. However, users might sometimes apply the attribute with the expectation that it can be used to suppress serializer errors if the property in question has been misconfigured. This is not the case, and the handling of such scenaria in System.Text.Json is largely undefined behavior.

That behavior can be inconsistent depending on the combination of attributes, and changes can result in broken applications like the one reported in #58469 (comment). In future releases we should try to ensure consistent semantics of the JsonIgnoreAttribute (e.g. by making that attribute suppress every other attribute) in both the reflection-based serializer and the source generator.

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.ComponentModel.DataAnnotations untriaged New issue has not been triaged by the area owner labels Sep 20, 2021
@ghost
Copy link

ghost commented Sep 20, 2021

Tagging subscribers to this area: @ajcvickers, @bricelam, @roji
See info in area-owners.md if you want to be subscribed.

Issue Details

The JsonIgnoreAttribute is a mechanism intended to prevent serialization or deserialization of a given property. However, users might sometimes apply the attribute with the expectation that it can be used to suppress serializer errors if the property in question has been misconfigured. This is not the case, and the handling of such scenaria in System.Text.Json is largely undefined behavior.

That behavior can be inconsistent depending on the combination of attributes, and changes can result in broken applications like the one reported in #58469 (comment). In future releases we should try to ensure consistent semantics of the JsonIgnoreAttribute (e.g. by making that attribute suppress every other attribute) in both the reflection-based serializer and the source generator.

Author: eiriktsarpalis
Assignees: -
Labels:

area-System.ComponentModel.DataAnnotations, untriaged

Milestone: -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Text.Json enhancement Product code improvement that does NOT require public API changes/additions Priority:3 Work that is nice to have
Projects
None yet
Development

No branches or pull requests

2 participants