禁用 StyleCop 规则
我正在使用 StyleCop。 但有一些规则我想忽略,例如在类成员前面使用 this.
。
如何关闭 StyleCop 规则。 我看过但找不到如何做。
I'm using StyleCop. But there a couple of rules I want to ignore, for instance using this.
in front of class members.
How do I turn off a StyleCop rule. I've looked but can't find how to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在您的 StyleCop 安装中,有一个
Settings.StyleCop
文件。 您可以编辑此项以全局关闭规则。 将该文件拖到该文件中的“设置编辑器”可执行文件中以对其进行编辑。您还可以将设置文件的副本放入项目中以覆盖全局设置。
如果您使用的是 Visual Studio 集成而不仅仅是 MSBuild 集成,您应该能够通过右键单击您的项目并选择
StyleCop Settings
或类似内容来按项目访问设置编辑器那。In your StyleCop install, there's a
Settings.StyleCop
file. You can edit this to turn off rules globally. Drag that file onto the Settings Editor executable in that file to edit it.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 Settings
or something like that.Stylecop 可在项目级别进行配置。 使用图形界面轻松管理规则,而不是编辑设置文件。(有时在某些版本中称为 Stylecop 设置)
选择设置选项后,您应该会看到一个搜索/查找选项,如下图所示。
例如:如果您想删除 stylecop 不允许 // 注释且允许 //// 的规则,则搜索 stylecop 规则 id。 在本例中为 SA1005。 当您在项目中运行 stylecop 时,您可以在警告部分看到这一点。 使用关键字 SA1005 进行查找,您应该会在结果部分中看到该内容。 取消选中即可。
您可以按如下方式管理规则
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)
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.
You can manage rules as below
该特定规则位于可读性规则 - 成员访问 - SA1101:PrefixLocalCallsWithThis 下。
如果你把它关掉,它就不会再对你尖叫了……我必须这么做。 Stylecop 一直让我头疼。
That specific rule is under Readability Rules - Member Access - 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.