Skip to content

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

Open

Description

@eiriktsarpalis

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.

Activity

  1. ghost added
    untriaged
    on Sep 20, 2021
  2. added this to the 7.0.0 milestone on Sep 20, 2021
  3. added
    enhancement
    Priority:3
    and removed
    untriaged
    on Sep 20, 2021
  4. modified the milestones: 7.0.0, Future on Jul 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:3area-System.Text.Jsonenhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions