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

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

Closed
layomia opened this issue Feb 2, 2020 · 2 comments
Closed
Labels
area-System.Text.Json test-enhancement Improvements of test source code
Milestone

Comments

@layomia
Copy link
Contributor

layomia commented Feb 2, 2020

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.

@layomia
Copy link
Contributor Author

layomia commented Jun 20, 2020

Closed in #32107 and related changes.

@layomia layomia closed this as completed Jun 20, 2020
@Simonl9l
Copy link

Curious minds...is System.Test.Json suppose to be a plugin replacement to Json.Net ? cause if so this is going the wrong direction - probably for a very broad development community that does to to re-write all their code.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Json test-enhancement Improvements of test source code
Projects
None yet
Development

No branches or pull requests

2 participants