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

Proposal: Add switch for treating nullable-related warnings as errors #44721

Closed
hez2010 opened this issue May 30, 2020 · 4 comments
Closed

Proposal: Add switch for treating nullable-related warnings as errors #44721

hez2010 opened this issue May 30, 2020 · 4 comments
Labels
Area-Compilers Feature Request New Language Feature - Nullable Reference Types Nullable Reference Types Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented

Comments

@hez2010
Copy link

hez2010 commented May 30, 2020

Version Used: .NET 5 Preview 4

If I want to treat all nullable-related warnings as errors, I have to treat CS8597 to CS8714 which declared in

WRN_ThrowPossibleNull = 8597,
as error in .csproj file manually, and it's really inconvenient.

I hope that there can have a switch to treat all nullable-related warnings as errors.

For example:

<PropertyGroup>
  <TreatNullableWarningAsError>true</TreatNullableWarningAsError>
</PropertyGroup>
@jcouv
Copy link
Member

jcouv commented Feb 9, 2021

There is already a compiler option to do this: -warnaserror: nullable from the command-line.
It should also work by passing "nullable" (in place of a specific diagnostic ID) to the "TreatWarningsAsErrors" "WarningsAsErrors" msbuild option.
<WarningsAsErrors>nullable</WarningsAsErrors>

I'll go ahead and close this issue as fixed. Thanks

@jcouv jcouv closed this as completed Feb 9, 2021
@jcouv jcouv added the Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented label Feb 9, 2021
@hez2010
Copy link
Author

hez2010 commented Apr 3, 2021

It works while building the project, but Visual Studio doesn't respect it and still produce warnings.

@jcouv
Copy link
Member

jcouv commented Apr 4, 2021

@hez2010 Indeed. Filed #52407 an issue (WarningsAsErrors should be honored in IDE too).

@hez2010
Copy link
Author

hez2010 commented Apr 4, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Feature Request New Language Feature - Nullable Reference Types Nullable Reference Types Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Projects
None yet
Development

No branches or pull requests

3 participants