对Visual Studio中的所有项目禁止显示警告 [英] Suppress a warning for all projects in Visual Studio
问题描述
我看到了一些答案,这些答案显示了如何禁止针对特定代码行或特定项目的警告.我不要那个.
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.
我想对我的项目 all 发出特定警告.
I want to suppress a specific warning for all of my projects.
(如果有问题,警告是IDE0044.我正在使用C#.)
(If it matters, the warning is IDE0044. And I'm using C#.)
推荐答案
Visual Studio 2017(15.7.1)的最新更新现在为此提供了一个选项.在Tools->Options
菜单下,选择TextEditor->C#->Code Style->General
选项卡.在Field preferences
下,有一个Prefer readonly
选项.将其设置为No
.
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
.
如果要在代码旁边检查此首选项,还可以设置editorconfig
设置,因此使用代码的其他人不会收到警告,但是必须针对每个解决方案进行设置基础.您将设置的editorconfig
值为:
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
这篇关于对Visual Studio中的所有项目禁止显示警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!