-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
New tests that JsonIncludeAttribute and JsonNumberHandlingAttribute are honored during deserialization #47904
Conversation
ArgumentDeserialization_Honors_JsonInclude test is added dotnet#47855
…zation ArgumentDeserialization_Honors_JsonNumberHandling test is added dotnet#47855
Tagging subscribers to this area: @eiriktsarpalis, @layomia Issue DetailsI added two test for checking the attributes during parameterized ctor deserialization.
|
Thanks for the PR @SkiFoD.
I just realized that with the current implementation, the attribute is indeed not necessary. I updated my comment at #47855 (comment) to reflect this. |
src/libraries/System.Text.Json/tests/Serialization/TestClasses/TestClasses.Constructor.cs
Show resolved
Hide resolved
src/libraries/System.Text.Json/tests/Serialization/TestClasses/TestClasses.Constructor.cs
Show resolved
Hide resolved
src/libraries/System.Text.Json/tests/Serialization/TestClasses/TestClasses.Constructor.cs
Show resolved
Hide resolved
public int X { get; } | ||
|
||
[JsonInclude] | ||
public int Y { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for variety, let this be one that has a private or internal setter.
public class Point_MembersHave_JsonInclude : ITestClass | ||
{ | ||
[JsonInclude] | ||
public int X { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add another property that has a non-public accessor, without the attribute, to show that deserialization works regardless. Then, add a comment that says we should add another test for non-public members when #31511 is implemented.
Thank you for your response @layomia. I made a new commit with the fixes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I added two test for checking the attributes during parameterized ctor deserialization.
ArgumentDeserialization_Honors_JsonNumberHandling test shows that JsonIncludeAttribute is not necessary when the deserialization occurs via ctor mapping even though the properties don't have setters.
This is the only thing that bothers me.
#47855