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

Adds tests for missing object and collection properties in S.T.J.S #34559

Merged
merged 2 commits into from
Apr 6, 2020

Conversation

marcusturewicz
Copy link
Contributor

@marcusturewicz marcusturewicz commented Apr 5, 2020

Adds two tests to ensure a missing object and a missing collection property are ignored when deserializing - the expected behaviour.

Not sure if this is what you wanted, let me know.

Fixes #32348

Adds two tests to ensure a missing object and a missing collection property are ignored when deserializing - the expected behaviour.

Fixes dotnet#32348
Copy link
Contributor

@layomia layomia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @steveharter on the intent of this comment/issue - #32348.

ClassWithMissingObjectProperty obj
= JsonSerializer.Deserialize<ClassWithMissingObjectProperty>(@"{ ""Object"": {} }");

Assert.NotNull(obj);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we don't need this line as we'll hit a null ref on the next.

ClassWithMissingCollectionProperty obj
= JsonSerializer.Deserialize<ClassWithMissingCollectionProperty>(@"{ ""Collection"": [] }");

Assert.NotNull(obj);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@steveharter steveharter merged commit 5346d57 into dotnet:master Apr 6, 2020
@marcusturewicz marcusturewicz deleted the issue-32348 branch April 6, 2020 22:29
@layomia layomia added this to the 5.0 milestone May 15, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests with missing object property and missing collection property.
4 participants