我们正在用了StyleCop在我们的C#项目。在某些情况下,我们想避免,虽然规则。我知道你可以添加 //<自动生成/>
在文件的开头,使了StyleCop忽略它。但是,我不想忽略规则的整个文件 - 都不会被code只有一个街区。
We're using StyleCop in our C# projects. In some cases we'd like to avoid the rules though. I know you can add // <auto-generated />
in the beginning of the file to make StyleCop ignore it. However, I don't want to ignore the rules for the whole file - only a block of code within it.
我可以禁用了StyleCop具体线不知何故?
Can I disable StyleCop for specific lines somehow?
您可以通过添加属性的code块燮preSS规则。下面是从博客文章链接如下一类简单的例子,但你可以做到这一点对各个成员分别:
You can suppress rules by adding attributes to blocks of code. Here's a simple example on a class from the blog post linked below, but you can do it on various members individually:
[SuppressMessage("Microsoft.StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented")]
public class MyUndocumentedClass
{
public void MyUndocumentedMethod {}
}
有一个快速浏览在一个MSDN博客文章和属性的完整的描述的MSDN上。
There's a quick overview at an MSDN blog post and a fuller description of the attributes on MSDN.