如何配置StyleCop以禁止生成代码的警告?

Jad*_*ias 6 .net code-analysis code-generation stylecop visual-studio

另一个项目,Visual Studio的代码分析有这个选项.但我找不到StyleCop(AKA Source Analysis).

我想忽略的文件是dbml的.designer.cs代码,其中包含// <autogenerated>标记.一篇博文告诉我这样就足够了,但就我而言,事实并非如此.

Sam*_*ell 6

StyleCop:如何忽略生成的代码

编辑:这是我在ANTLR的生成语法中使用的标题.这实际上是StringTemplate模板的主体,因此这两个\>条目实际上只是转义>标记.除了<auto-generated>标记和[GeneratedCode]属性之外,我们仍然必须禁用在代码分析期间出现的一些警告.

//------------------------------------------------------------------------------
// \<auto-generated>
//     This code was generated by a tool.
//     ANTLR Version: ANTLRVersion
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// \</auto-generated>
//------------------------------------------------------------------------------

// $ANTLR <ANTLRVersion> <fileName>

// The variable 'variable' is assigned but its value is never used.
#pragma warning disable 219
// Unreachable code detected.
#pragma warning disable 162
// Missing XML comment for publicly visible type or member 'Type_or_Member'
#pragma warning disable 1591
// CLS compliance checking will not be performed on 'type' because it is not visible from outside this assembly.
#pragma warning disable 3019
// 'type' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute.
#pragma warning disable 3021

[System.CodeDom.Compiler.GeneratedCode("ANTLR", "<ANTLRVersion>")]
[System.CLSCompliant(false)]
public class ...
Run Code Online (Sandbox Code Playgroud)

  • 它在当前版本中不起作用.我不是唯一一个抱怨它的人,他们的bug跟踪器中有更多的人. (2认同)