在全局范围内禁止StyleCop警告 [英] Suppressing the StyleCop Warnings at the global level

查看:102
本文介绍了在全局范围内禁止StyleCop警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在解决方案中全局禁止StyleCop警告?

How to suppress the StyleCop warnings globally in the solution?

该解决方案使用Jenkins(连续构建和集成工具)连续构建,并应用了所有StyleCop规则.该解决方案使用TAB字符而不是4个空格,因为这是我的开发团队所采用的标准.因此,StlyeCop会引发几个SA1027警告.

The solution is continually built using Jenkins (continuous build and integration tool), and it applies all the StyleCop rules. The solution uses TAB character instead of 4 spaces as it is the standard taken by my dev team. Because of this, several SA1027 warnings are thrown by StlyeCop.

如何从詹金斯删除SA1027警告?这也有帮助.

How do I remove SA1027 warning from Jenkins? That would also help.

在每个C#文件上提供SuppressMessage看起来并不好.这就是为什么我正在寻找一种全局抑制方法.

Giving the SuppressMessage on every C# file would not look nice. That's why I am looking for a global suppression approach.

推荐答案

StyleCop不支持规则的全局抑制概念.它要求将SuppressMessage属性放在给定的代码元素上.

StyleCop doesn't support the notion of global suppression of a rule. It requires the SuppressMessage attribute be placed on the given code element.

从源代码分析博客()

StyleCop不支持全局抑制或文件级抑制的概念.禁止必须放置在代码元素上.

StyleCop does not support the notion of global suppressions or file-level suppressions. Suppressions must be placed on a code element.

但是,一种选择是简单地关闭您不感兴趣的规则.这是全局抑制的首选方法.

One option though is to simply turn off the rules that you aren't interested in. This is the preferred method of global suppression.

这篇关于在全局范围内禁止StyleCop警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆