How to configure StyleCop to suppress warnings on generated code?

后端 未结 1 1728
感动是毒
感动是毒 2021-01-05 14:59

Another project, Visual Studio\'s Code Analysis has this option. But I couldn\'t find it for StyleCop (AKA Source Analysis).

The file I want to ignore is a dbml\'s .

1条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-05 15:59

    StyleCop: How To Ignore Generated Code

    Edit: Here is the header I use in generated grammars for ANTLR. This is actually the body of a StringTemplate template, so the two \> entries are actually just escaped > marks. Aside from the tag and the [GeneratedCode] attribute, we still had to disable some warnings which appeared during code analysis.

    //------------------------------------------------------------------------------
    // \
    //     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.
    // \
    //------------------------------------------------------------------------------
    
    // $ANTLR  
    
    // 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", "")]
    [System.CLSCompliant(false)]
    public class ...
    

    0 讨论(0)
提交回复
热议问题