I've seen answers showing how to suppress a warning for a specific line of code or for a specific project. I don't want that.
I want to suppress a specific warning for all of my projects.
(If it matters, the warning is IDE0044. And I'm using C#.)
A recent update to Visual Studio 2017 (15.7.1) has an option for this now. Under the Tools->Options
menu, select the TextEditor->C#->Code Style->General
tab. Under Field preferences
, there is a Prefer readonly
option. Set that to No
.
There is also an editorconfig
setting you can set if you want to check this preference in along side your code, so others who consume your code don't get the warning, but that has to be done on a per solution basis. The editorconfig
value you would set would be:
dotnet_style_readonly_field = false:none