-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix NRT warnings in source generated code #59755
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
Fix NRT warnings in source generated code #59755
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-text-json Issue DetailsAddresses an issue where STJ source generated code can result in warnings in cases where member types contain nullable reference type annotations. Also updates the annotations for fast-path serialize methods so that the input value type is nullable for the case of reference types. Note that the implementation intentionally does not take Roslyn nullability metadata into account when inserting suppresions. This is due to a restriction in our current sourcegen infrastructure which abstracts the Roslyn symbols as System.Reflection types: since nullability metadata is not available in that layer it ends up being erased. We should consider changing this in .NET 7.0.0. Should be considered for 6.0.0 servicing. Fix #59464.
|
...t.Json/tests/System.Text.Json.SourceGeneration.Tests/MetadataAndSerializationContextTests.cs
Show resolved
Hide resolved
...ries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/RealWorldContextTests.cs
Show resolved
Hide resolved
.../System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/SerializationContextTests.cs
Show resolved
Hide resolved
layomia
left a comment
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.
LGTM
src/libraries/System.Text.Json/gen/Reflection/TypeExtensions.cs
Outdated
Show resolved
Hide resolved
|
/backport to release/6.0 |
|
Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1291940989 |
Addresses an issue where STJ source generated code can result in warnings in cases where member types contain nullable reference type annotations. Also updates the annotations for fast-path serialize methods so that the input value type is nullable for the case of reference types.
Note that the implementation intentionally does not take Roslyn nullability metadata into account when inserting suppresions. This is due to a restriction in our current sourcegen infrastructure which abstracts the Roslyn symbols as System.Reflection types: since nullability metadata is not available in that layer it ends up being erased. We should consider changing this in .NET 7.0.0.
Should be considered for 6.0.0 servicing.
Fix #59464.