如何对某些 StyleCop 规则做出例外?
可能的重复:
如何抑制 StyleCop 警告?
目前,我正在为我们的项目设置 StyleCop我偶然发现了 StyleCop 的一项规则。这是关于SA1300的命名规则:
SA1300:命名空间名称以 大写字母:iCompanyName。
所以我的公司以小写字母开头。各种产品名称也是如此。因此,是否有可能在 Settings.StyleCop 文件中添加此规则的例外情况?
我想阻止使用 C# 编写自定义 StyleCop 规则。
预先感谢您的回复。
编辑: 我意识到我应该注意到我实际上并不想完全禁用/抑制 StyleCop 规则。我只想对这个命名规则做一些例外。
Possible Duplicate:
How to suppress a StyleCop warning?
Currently I'm setting up StyleCop for our projects and I stumbled on one rule of StyleCop. It's about the SA1300 naming rule:
SA1300: namespace names begin with an
upper-case letter: iCompanyName.
So my company starts with a lower-case letter. And various product names do also. Therefore, is there a possibility to add exceptions to this rule in the Settings.StyleCop file?
I'd like to prevent to write custom StyleCop rules using C#.
Thanks in advance for your replies.
edit:
I realize I should have noted that I don't actually want to disable/suppress the StyleCop rule completely. I'd just like to make some exceptions on this naming rule.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SA1300 规则不可配置(至少在版本 4.4 中)。如果您不喜欢其行为并且不想完全禁用该规则,则需要使用替代自定义规则。您也许可以从第三方找到一个可用的项目,例如 StyleCop+ 项目。如果没有,你就只能自己动手了……
The SA1300 rule is not configurable (at least in version 4.4). If you don't like its behaviour and don't want to disable the rule entirely, you will need to use a substitute custom rule. You might be able to find one available from a third-party such as the StyleCop+ project. If not, you're pretty much stuck rolling your own...
您可以根据具体情况抑制该消息,如 StyleCop 网站 - http: //stylecop.codeplex.com/wikipage?title=Rule%20Suppressions
另外,看看这个问题 - 如何抑制 StyleCop 警告?
You can suppress the message on a case by case basis as described on the StyleCop site - http://stylecop.codeplex.com/wikipage?title=Rule%20Suppressions
Also, have a look at this question - How to suppress a StyleCop warning?