Skip to content

Roslyn does not support csc -warnnotaserrorΒ #34900

@KalleOlaviNiemitalo

Description

@KalleOlaviNiemitalo

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.


Associated WorkItem - 479146

Metadata

Metadata

Labels

πŸ“Œ seQUESTeredIdentifies that an issue has been imported into Quest.dotnet-csharp/svcin-prThis issue will be closed (fixed) by an active pull request.lang-reference/subsvcokr-qualityContent-quality KR: Concerns article defects (bugs), freshness, or build warnings.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions