-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
At C# Compiler Options to report errors and warnings, it says
- TreatWarningsAsErrors /
-warnaserror
: Treat all warnings as errors- WarningsAsErrors /
-warnaserror
: Treat one or more warnings as errors- WarningsNotAsErrors /
-warnnotaserror
: Treat one or more warnings not as errors
but actually the command-line option that corresponds to WarningsNotAsErrors appears to be -warnaserror-
(e.g. -warnaserror-:CS4014
) rather than -warnnotaserror
. MSBuild supports -warnNotAsError
, but the doc page says "The older csc.exe syntax is shown in code style
", so the page should show csc.exe options rather than MSBuild options.
The claimed -warnnotaserror
option does not appear anywhere in the Roslyn source code. There is OPTID_WARNNOTASERRORLIST
in ProjectSystemShim, though.
Also, WarningsAsErrors is mapped to -warnaserror+
rather than just -warnaserror
. Because MSBuild can display -warnaserror+
in the generated csc.exe command line, it would be good to document that, even though Roslyn treats -warnaserror+
as equivalent to -warnaserror
and instead decides the meaning from whether the option has an argument.
https://github.com/dotnet/roslyn/blob/6a5a63bbc9f4449d9bd1e95a8f9624939c3ccdc3/src/Workspaces/Core/MSBuild/MSBuild/CSharp/CSharpCommandLineArgumentReader.cs#L58-L60
https://github.com/dotnet/roslyn/blob/6a5a63bbc9f4449d9bd1e95a8f9624939c3ccdc3/src/Compilers/CSharp/Portable/CommandLine/CSharpCommandLineParser.cs#L876-L939
Document Details
β Do not edit this section. It is required for learn.microsoft.com β GitHub issue linking.
- ID: 26ef35c2-6df4-26f8-32b2-9b50eb76c037
- Version Independent ID: e57ac82b-307e-163b-8172-52644b3a6baa
- Content: C# Compiler Options - errors and warnings
- Content Source: docs/csharp/language-reference/compiler-options/errors-warnings.md
- Product: dotnet-csharp
- Technology: csharp-language-reference
- GitHub Login: @BillWagner
- Microsoft Alias: wiwagn