Roslyn: Provide single option to treat nullable issues as errors not warnings

Created on 12 Feb 2020  路  5Comments  路  Source: dotnet/roslyn

Version Used:

VS 2019 16.4.2

Steps to Reproduce:

You can enable new nullable checking for C# 8.0 with entry

<Nullable>enable</Nullable>

in your csproj file which triggers warnings. You can turn warnings into errors with:

<WarningsAsErrors>CS8600;CS8602;CS8603;CS8613;CS8601;CS8625;CS8604;CS8618</WarningsAsErrors>

the problem is, when you read this list it is hard to know by heart that switch CSXXX refers to nullable checking. And also when Roslyn will come up with some extra check you will need to update your settings.

Expected Behavior:

Please provide another value for Nullable tag:

<Nullable>errors</Nullable>

Which would automatically report ALL issues as errors without the need to manually add this and that report to WarningsAsErrors list.

Actual Behavior:

You need to manually specify each warning to be treated as errors -- tiresome and not very readable.

Area-Compilers Documentation

Most helpful comment

You can already do that by passing nullable to WarningsAsErrors (or /warnaserror:nullable from the command-line).

All 5 comments

You can already do that by passing nullable to WarningsAsErrors (or /warnaserror:nullable from the command-line).

Tagging @jaredpar @BillWagner: Both NoWarn and WarnAsError support the nullable shorthand for the long list of nullable warnings, but it is not well documented or known at this point.

I'll add a mention to the command-line help.
What other places do you think we should document this?

I'm adding mentions of "nullable" to csc -help message in PR https://github.com/dotnet/roslyn/issues/41605

Created a docs PR to also document on warnaserror (PR https://github.com/dotnet/docs/pull/17094)

Added documentation for "nullable" warning set to csc -help (in 16.6p1) and updated docs to mention it too. Closing

Was this page helpful?
0 / 5 - 0 ratings