visual-studio 禁用 StyleCop 规则
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/643331/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Disabling StyleCop rules
提问by AJM
I'm using StyleCop. But there a couple of rules I want to ignore, for instance using this.in front of class members.
我正在使用 StyleCop。但是有一些规则我想忽略,例如this.在班级成员面前使用。
How do I turn off a StyleCop rule. I've looked but can't find how to do it.
如何关闭 StyleCop 规则。我已经看过了,但找不到怎么做。
回答by bdukes
In your StyleCop install, there's a Settings.StyleCopfile.  You can edit this to turn off rules globally.  Drag that file onto the Settings Editor executable in that file to edit it.
在您的 StyleCop 安装中,有一个Settings.StyleCop文件。您可以编辑它以全局关闭规则。将该文件拖到该文件中的 Settings Editor 可执行文件上以对其进行编辑。
You can also put copies of the settings file into your projects to override the global settings.
您还可以将设置文件的副本放入项目中以覆盖全局设置。
If you're using Visual Studio integration and not just MSBuild integration, you should be able to get to the settings editor on a per-project basis by right clicking on your project and choosing StyleCop Settingsor something like that.
如果您使用的是 Visual Studio 集成,而不仅仅是 MSBuild 集成,那么您应该能够通过右键单击您的项目并选择StyleCop Settings或类似的方式,在每个项目的基础上进入设置编辑器。
回答by Kurkula
Stylecop is configurable at Project level. Manage rules easily using graphical interface instead of editing settings file.(Some time in some versions mentioned as Stylecop settings)
Stylecop 可在项目级别进行配置。使用图形界面而不是编辑设置文件轻松管理规则。(有时在某些版本中称为 Stylecop 设置)
You should see a search/Find Option once you select the settings option as in the below image.
选择下图所示的设置选项后,您应该会看到搜索/查找选项。
Ex: If you want to remove a rule where // comments are not allowed and //// are allowed by stylecop, then search for stylecop rule id. In this case it is SA1005. You can see this in the warnings section when you run stylecop in your project. Find with key word SA1005 and you should see that in result section. Just uncheck.
例如:如果要删除 // 不允许注释而 stylecop 允许 /// 的规则,则搜索 stylecop 规则 ID。在这种情况下,它是 SA1005。当您在项目中运行 stylecop 时,您可以在警告部分看到这一点。使用关键字 SA1005 查找,您应该在结果部分看到它。只需取消选中。
You can manage rules as below
您可以管理如下规则
回答by DeadlyChambers
That specific rule is under Readability Rules - Member Access - SA1101: PrefixLocalCallsWithThis.
该特定规则位于可读性规则 - 成员访问 - SA1101:PrefixLocalCallsWithThis 下。
If you turn that off it should stop screaming at you... I had to do it. Stylecop has been giving me a headache.
如果你把它关掉,它应该停止对你尖叫......我不得不这样做。Stylecop 一直让我头疼。


