Skip to content

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

Merged
steveharter merged 2 commits into
dotnet:masterfrom
marcusturewicz:issue-32348
Apr 6, 2020
Merged

steveharter merged 2 commits into
dotnet:masterfrom
marcusturewicz:issue-32348

Conversation

@marcusturewicz

@marcusturewicz marcusturewicz commented Apr 5, 2020 •

Copy link
Copy Markdown
Contributor

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

@layomia layomia left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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