6
另一个项目,Visual Studio的代码分析有这个选项。但我找不到StyleCop(又名源分析)。如何配置StyleCop以抑制生成的代码警告?
我想忽略的文件是dbml的.designer.cs代码,它包含// <autogenerated>
标记。 A blog post告诉我,这将是足够的,但在我的情况下,它不是。
另一个项目,Visual Studio的代码分析有这个选项。但我找不到StyleCop(又名源分析)。如何配置StyleCop以抑制生成的代码警告?
我想忽略的文件是dbml的.designer.cs代码,它包含// <autogenerated>
标记。 A blog post告诉我,这将是足够的,但在我的情况下,它不是。
StyleCop: How To Ignore Generated Code
编辑:这是我在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 ...
它在当前版本中不起作用。我不是唯一抱怨的人,他们的bug跟踪器中有更多的人。 – 2009-10-19 18:31:14
-1:这不是问题:Jader并没有问是否有其他选项可以忽略自动生成的代码,而是为什么它不工作'//'方式。我认为每个可以谷歌的人都会首先在你的链接页面上,但如果它不起作用,它将无济于事。它也不适用于我,即使我的文件确实是自动生成的,并且头文件已由该软件设置。 –
2011-04-09 01:43:38
该博客帖子中的链接不再有效。最好在这里发布答案,而不是张贴链接。 – 2011-12-23 15:04:31