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

[STJ] Add support for nullable reference annotations on properties #102499

Merged
merged 19 commits into from
May 22, 2024

Conversation

eiriktsarpalis
Copy link
Member

  • Adds support for nullable reference type annotations on JSON property metadata.
  • Refactors the implementation of JsonParameterInfo metadata such that properties and constructor parameters are associated early in the contract resolution process and annotations of both feed into the JsonPropertyInfo.DisallowNullReads property.

Fix #100144

Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

@eiriktsarpalis eiriktsarpalis marked this pull request as ready for review May 22, 2024 09:12
@jozkee jozkee requested review from krwq and stephentoub and removed request for krwq and stephentoub May 22, 2024 15:07
Copy link
Member

@jozkee jozkee left a comment

Choose a reason for hiding this comment

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

LGTM, thanks a lot for taking over.

@eiriktsarpalis eiriktsarpalis merged commit 455f540 into dotnet:main May 22, 2024
143 of 146 checks passed
@eiriktsarpalis eiriktsarpalis deleted the json-nrt2 branch May 22, 2024 18:47
@eiriktsarpalis eiriktsarpalis restored the json-nrt2 branch May 22, 2024 18:47
steveharter pushed a commit to steveharter/runtime that referenced this pull request May 28, 2024
…otnet#102499)

* Progress so far on nullability annotations

* Complete implementation and make all NullableAnnotations tests pass.

* Update annotations for all failing unit tests.

* Update src/libraries/System.Text.Json/gen/Helpers/RoslynExtensions.cs

* Update src/libraries/System.Text.Json/gen/Helpers/RoslynExtensions.cs

* Address feedback

* Update to latest approved API and semantics.

* Update src/libraries/System.Private.CoreLib/src/System/Reflection/NullabilityInfoContext.cs

Co-authored-by: David Cantú <[email protected]>

* Update src/libraries/System.Private.CoreLib/src/System/Reflection/NullabilityInfoContext.cs

Co-authored-by: David Cantú <[email protected]>

* Update src/libraries/System.Text.Json/gen/JsonSourceGenerator.Emitter.cs

Co-authored-by: David Cantú <[email protected]>

* Rename more ignoreNullableAnnotations stragglers.

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs

Co-authored-by: David Cantú <[email protected]>

* Remove commented out code and address feedback.

* Update src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Tests.targets

Co-authored-by: David Cantú <[email protected]>

* Ensure the original parameter name flows exception messages.

* Extract exceptions to a throw helper in the new properties.

* Extend test coverage to Nullable<T> properties.

* Revert sln changes

* Add second-pass review improvements.

---------

Co-authored-by: David Cantú <[email protected]>
@sebastienros
Copy link
Member

@eiriktsarpalis this is breaking the ASP.NET E2E tests as we ingested it for preview5. Here are the logs

https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_apis/build/builds/690914/logs/40

Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this pull request May 30, 2024
…otnet#102499)

* Progress so far on nullability annotations

* Complete implementation and make all NullableAnnotations tests pass.

* Update annotations for all failing unit tests.

* Update src/libraries/System.Text.Json/gen/Helpers/RoslynExtensions.cs

* Update src/libraries/System.Text.Json/gen/Helpers/RoslynExtensions.cs

* Address feedback

* Update to latest approved API and semantics.

* Update src/libraries/System.Private.CoreLib/src/System/Reflection/NullabilityInfoContext.cs

Co-authored-by: David Cantú <[email protected]>

* Update src/libraries/System.Private.CoreLib/src/System/Reflection/NullabilityInfoContext.cs

Co-authored-by: David Cantú <[email protected]>

* Update src/libraries/System.Text.Json/gen/JsonSourceGenerator.Emitter.cs

Co-authored-by: David Cantú <[email protected]>

* Rename more ignoreNullableAnnotations stragglers.

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs

Co-authored-by: David Cantú <[email protected]>

* Remove commented out code and address feedback.

* Update src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Tests.targets

Co-authored-by: David Cantú <[email protected]>

* Ensure the original parameter name flows exception messages.

* Extract exceptions to a throw helper in the new properties.

* Extend test coverage to Nullable<T> properties.

* Revert sln changes

* Add second-pass review improvements.

---------

Co-authored-by: David Cantú <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Jun 29, 2024
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 a STJ feature flag recognizing nullable reference type annotations on properties
3 participants