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

[release/7.0] Disable nullability warnings in JSON source generator #74861

Merged
merged 2 commits into from
Sep 1, 2022

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Aug 31, 2022

Backport of #74801 to release/7.0

/cc @eiriktsarpalis @krwq

Customer Impact

Customers have reported that certain nullability annotations cause JSON source-gen to generate code which produce code with warnings. Some libraries (i.e. Microsoft.Extensions.Primitives) added nullability annotations to their libraries and customers upgrading now start seeing nullability warnings. This is super annoying for users as they cannot suppress them in the source code and in certain situations where treating warnings as errors is enabled may cause build errors.

While this is not a regression in JSON itself, combination of this bug with new nullability annotations is a regression from product perspective.

Related issues:

Testing

Customer reported scenarios are added as tests, existing scenarios are already tested.

Risk

Minimal - product change is limited to disabling nullability warnings in the generated code.

IMPORTANT: Is this backport for a servicing release? If so and this change touches code that ships in a NuGet package, please make certain that you have added any necessary package authoring and gotten it explicitly reviewed.

@ghost
Copy link

ghost commented Aug 31, 2022

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

Issue Details

Backport of #74801 to release/7.0

/cc @eiriktsarpalis @krwq

Customer Impact

Testing

Risk

IMPORTANT: Is this backport for a servicing release? If so and this change touches code that ships in a NuGet package, please make certain that you have added any necessary package authoring and gotten it explicitly reviewed.

Author: github-actions[bot]
Assignees: -
Labels:

area-System.Text.Json

Milestone: -

@eiriktsarpalis
Copy link
Member

IMPORTANT: Is this backport for a servicing release? If so and this change touches code that ships in a NuGet package, please make certain that you have added any necessary package authoring and gotten it explicitly reviewed.

@carlossanlop I'm guessing this does not apply to RC fixes right?

@danmoseley
Copy link
Member

Approved, we would potentially service for it.

#nullable enable

#nullable enable annotations
#nullable disable warnings
Copy link
Member

Choose a reason for hiding this comment

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

Are we ever generating public API? With annotations enabled we will still be outputting nullability metadata, and if we have reason to believe that the annotations are incorrect, that'll mean incorrect nullability information surfaced to consumers of the APIs.

If this is all internal to the assembly, it's probably fine. If it's not, we might instead consider doing:

#nullable disable
#pragma warning disable CS8632

instead, or something along those lines.

Copy link
Member

Choose a reason for hiding this comment

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

@eiriktsarpalis do you want to resolve this question before I hit merge?

Copy link
Member

Choose a reason for hiding this comment

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

Yes let's please resolve this q first.

Copy link
Member

Choose a reason for hiding this comment

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

we do produce some public APIs - AFAIK they're correct though

Copy link
Member

Choose a reason for hiding this comment

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

they're correct though

Ok

@carlossanlop
Copy link
Member

I'm guessing this does not apply to RC fixes right?

Correct, not needed for RCs.

@@ -112,6 +112,10 @@
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\DynamicallyAccessedMemberTypes.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Primitives\src\Microsoft.Extensions.Primitives.csproj" />
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't feel right to me. I know these are tests, but having something in System depend on things in Microsoft.Extensions feels backwards.

Is there something about StringValues that we can isolate into a unit test type? Or do we actually have to use the StringValues type in order to test the scenario?

Copy link
Member

Choose a reason for hiding this comment

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

StringValues is what customer reported so it was added here as a test to make sure that specific scenario works. I think that should be fine for tests, we already depend on other things like JSON.NET

@krwq krwq merged commit 608da95 into release/7.0 Sep 1, 2022
@akoeplinger akoeplinger deleted the backport/pr-74801-to-release/7.0 branch September 1, 2022 14:25
@ghost ghost locked as resolved and limited conversation to collaborators Oct 1, 2022
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.

6 participants