Ogglas
Ogglas

Reputation: 70008

Visual Studio 2022 - Errors and warnings - can't change Warning level

I'm using Microsoft Visual Studio 2022 (64-bit) - 17.2.2. When I change project properties for a .NET 6 project I cant change Errors and warnings - Warning level. My current level is 6 - Warnings from C# 10

I'm trying to set this to either 7 - Warnings from C# 11 or 9999 - All warnings. What happens is I can set the value but the value is restored to 6 - Warnings from C# 10.

enter image description here

Setting other values work as expected.

Warning Level:

Specifies the level to display for compiler warnings. Higher levels produce more warnings, and include all warnings from lower levels.

https://learn.microsoft.com/en-us/visualstudio/ide/reference/build-page-project-designer-csharp?view=vs-2022#errors-and-warnings

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/errors-warnings#warninglevel

Upvotes: 5

Views: 5347

Answers (2)

Aritz
Aritz

Reputation: 184

I have been trying to disable some of the Visual Studio 2022 warnings, in particular the ones that warns about a possible null value when declaring a class.

After several searches I haven't found a correct way to do it properly, I'm trying to generate noise in the code and keep the solution as clear as possible.

In this case I want to disable CS8618 and CS8601, if possible at IDE level, or in case it has to be at project level, set some directive in a file that can be shared to have the same configuration at team level.

The closest thing has been Microsoft's guide How to: Suppress compiler warnings, but I want to go a little further and find out if there is a more global and cleaner solution.

Upvotes: 0

Ogglas
Ogglas

Reputation: 70008

It seems to be a GUI bug. Even if the value is restored to 6 - Warnings from C# 10 in Visual Studio the .csproj file still gets modified if I press the save button with a value like <WarningLevel>9999</WarningLevel>.

enter image description here

Upvotes: 1

Related Questions