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#.)
In Visual Studio, you have to set the warning(s) to ignore for each individual database object in the project. Select the file and add the warning(s) to ignore in the Suppress TSql Warnings entry in the File Properties window. Do this for each file.
Use a #pragma warning (C#) or Disable (Visual Basic) directive to suppress the warning for only a specific line of code.
You can make all warnings being treated as such using -Wno-error. You can make specific warnings being treated as such by using -Wno-error=<warning name> where <warning name> is the name of the warning you don't want treated as an error. If you want to entirely disable all warnings, use -w (not recommended).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With