Open
Description
Type of issue
Other (describe below)
Description
In the WarningLevel section (link), there is a note about the use of AnalysisLevel
which suggests that setting AnalysisLevel
will also set WarningLevel
to match.
However, I think this information is incorrect or misleading.
Example project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<AnalysisLevel>none</AnalysisLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
</Project>
Example Program.cs:
class program
{
static void Main() { }
}
Output of dotnet build
:
MSBuild version 17.9.8+b34f75857 for .NET
Determining projects to restore...
Restored /proof/proof.csproj (in 57 ms).
/proof/Program.cs(1,7): error CS8981: The type name 'program' only contains lower-cased ascii characters. Such names may become reserved for the language. [/proof/proof.csproj]
Build FAILED.
/proof/Program.cs(1,7): error CS8981: The type name 'program' only contains lower-cased ascii characters. Such names may become reserved for the language. [/proof/proof.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.75
Why does the build still report a warning wave 7 error?
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/warning-waves#cs8981---the-type-name-only-contains-lower-cased-ascii-characters
I expected warning wave 7 to be disabled by setting AnalysisLevel
to none
in my csproj ❓
The warning disappears when I run dotnet build --no-incremental /p:WarningLevel=6
or lower.
Page URL
Content source URL
Document Version Independent Id
e57ac82b-307e-163b-8172-52644b3a6baa
Article author
Metadata
- ID: 26ef35c2-6df4-26f8-32b2-9b50eb76c037
- Service: dotnet-csharp
- Sub-service: lang-reference