如何从代码分析中排除自动生成的文件 [英] How to exclude auto-generated file from code analysis

查看:88
本文介绍了如何从代码分析中排除自动生成的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Team,


我使用OData客户端代码生成器为odata服务生成代理。我能够成功生成服务代理,但是当我尝试构建应用程序时,它会给出代码分析错误,以下是以下观察结果, 


< autogenerated>标签存在于xml doc


< code analysis>也被抑制 


但是,在这里我不想压制它,而是代码分析应该忽略自动生成的文件。我请你指导我解决这个问题



谢谢,


Abhinandan




Abhinandan MS

解决方案

嗨AbhinandanMS,


如果您想使用VS代码分析工具,并且您的项目使用OData客户端代码生成器为odata服务生成代理,则在分析项目时忽略/排除它们很困难,除非您使用Fxcop工具。对于FxCop,
最终方法是使用[GeneratedCode]属性修饰代码并禁用检查生成代码的选项。


参考:


https://social.msdn.microsoft.com/Forums/en-US/9d4d79f7-3dfa-4100-8154-13e45d9ab0c6/how- do-i-exclude-whole-dlls-that-do-do-not-want-fxcop-to-check?forum = vstscode


https://social.msdn.microsoft.com/Forums/en-US/40b11852-9288-4a07-9967-c4b1c69a0edc/how-can-i-exclude-one-of-referenced-assemblies-from-代码分析?论坛= vstscode


Hi Team,

I have used OData Client Code generator to generate the proxy for an odata service. I am able generate the service proxy successfully, but when I tried to build the application, it is giving code analysis error and following are the below observations, 

<autogenerated> tag is there in xml doc

<code analysis> is also suppressed 

But, here I do not want to suppress it, instead the code analysis should ignore the auto generated files. I request you to guide me in solving this

Thanks,

Abhinandan


Abhinandan MS

解决方案

Hi AbhinandanMS,

If you want to use the VS code analyze tool, and your projects used OData Client Code generator to generate the proxy for an odata service, it is difficult to ignore/exclude them when we analyze the projects unless you use the Fxcop tool. For FxCop, the definitive method is to decorate your code with a [GeneratedCode] attribute and disable the option to check generated code.

Reference:

https://social.msdn.microsoft.com/Forums/en-US/9d4d79f7-3dfa-4100-8154-13e45d9ab0c6/how-do-i-exclude-entire-dlls-that-i-do-not-want-fxcop-to-check?forum=vstscode

https://social.msdn.microsoft.com/Forums/en-US/40b11852-9288-4a07-9967-c4b1c69a0edc/how-can-i-exclude-one-of-referenced-assemblies-from-code-analyze?forum=vstscode


这篇关于如何从代码分析中排除自动生成的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆