使用StyleCop分析器的Visual Studio 2015代码分析
问题描述:
我正在使用Visual Studio 2015以及NuGet包StyleCop分析器进行代码分析。当我运行代码分析时,我也收到了由实体框架生成的类自动生成的代码或添加的服务引用的警告。使用StyleCop分析器的Visual Studio 2015代码分析
我生成的文件头部包含
//-----------------------------------------------------------------------
// <copyright company="SomeCompany" file="MyFile.cs">
// Copyright © Some Company, 2011
// </copyright>
// <auto-generated />
//-----------------------------------------------------------------------
或
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
在项目中,我可以选择“禁止从生成代码的结果”启用
,如何排除我代码分析生成的代码?
答
继汉斯帕桑特的评论我改变我的实体框架模型
的文本模板添加了以下属性我生成的类[GeneratedCode(“EntityModelCodeGenerator”,“6.1.3”)
公共部分类.... {}
的类现在通过代码分析
注释是肯定不够好跳过,它需要[GeneratedCode] ATTRIB UTE。 –