Skip to content

[Tests] Ensure JsonSerializer doesn't (de)serialize non-public properties #31633

Description

@layomia

Follow up from #2278.

We should add some tests ensuring that the serializer doesn't deserialize/serialize non-public properties under any circumstance including:

  • when a derived type adds a non-public new property which collides with a public property defined on the parent
  • when there are property name collisions between public/non-public properties due to [JsonPropertyName]
  • when there are property name collisions between public/non-public properties due to JsonNamingPolicy

all such tests should have variants checking that public properties that are [JsonIgnore]'d are not accidentally (de)serialized due to mismatching JsonPropertyInfo with a colliding non-public member.

https://dotnetfiddle.net/2BD7bK goes over a few expecations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions