CA:抑制生成的代码在 VS2010 beta 2 中不起作用的结果
我正在尝试对包含实体模型(edmx 文件)的程序集运行代码分析。在项目属性中,我已选中“抑制生成代码的结果”选项,但我仍然收到许多与自动生成的 EF 代码相关的 CA 错误。
有人经历过这个吗?有解决方法吗?
I'm trying to run codeanalysis on an assembly that contains an entity model (edmx file). In project properties I have checked the "Suppress results from generated code" option, but I am still getting a lot of CA errors pertaining to the auto-generated EF code.
Has anyone experienced this? And is there a work-around?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需将属性放在类定义中即可。
但如何做到这一点,因为您的文件随时可能被覆盖。使用单独的文件,因为所有生成的类都是部分类。打开一个单独的文件,并编写如下内容:
这将跳过对特定生成的类的代码分析。例如,StyleCop 更智能,不会触及名称中包含
.designer/.generate
部分的文件或名称中包含generate
单词的区域。Just put the attribute on your class definition.
But how to do it, since your file can get overridden any time. Use a separate file, since all generated classes are partial classes. Open a separate file, and write something like:
This will skip code analysis on your particular generated class. StyleCop for instance is more smart and doesn't touch files that have
.designer/.generated
part in their name or regions that havegenerated
word in their name.好吧,“抑制生成代码的结果”实际上意味着“不要使用
GenelatedCodeAttribute
查看类型”。 EF 的代码生成器历史上未添加此功能(尽管我已向团队建议过)。但是如果您使用自定义 T4。Well, "Suppress results from generated code" really means "Don't look at types with
GeneratedCodeAttribute
". EF's code generator hasn't added this, historically (though I've suggested it to the team). But you can add it if you use custom T4.