Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2019: how to disable specific CodeAnalysis messages in .editorconfig?

Is it possible to suppress CodeAnalysis messages in VS 2019 .editorconfig ? These two options don't work:

[*.cs]
#Trying alternatives to
#[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "<Pending>")]
dotnet_diagnostic.CA1051.severity = silent 
dotnet_analyzer_diagnostic.CA1051.severity = silent 
like image 919
Roman Pokrovskij Avatar asked Sep 18 '25 05:09

Roman Pokrovskij


1 Answers

Yes, rule severity is configurable in an EditorConfig file in Visual Studio 2019 version 16.3 or newer (MSDN).

To suppress a rule violation, you should set the severity to none:

dotnet_diagnostic.CA1051.severity = none

This worked for me after I edited the config file and restarted Visual Studio.

like image 108
Stephen Kennedy Avatar answered Sep 20 '25 21:09

Stephen Kennedy