How to prevent FxCop from analyzing auto-generated code?

隐身守侯 提交于 2019-12-09 15:27:21

问题


FxCop (tool for static code analysis) gives me an error while checking code behind of .edmx model. How to prevent FxCop from analyzing auto-generated code (or at least Entity Framework generated classes)?


回答1:


I have moved to Visual Studio Code Analysis, as it gives me the same functionality as FxCop.

From FxCop blog:

"That's correct, they are different products (FxCop and VS Code Analysys), however they do have a common engine. Visual Studio 2008 SP1 already comes with the same fixes and analysis (plus a little bit more), so there is no need to 'update' Visual Studio with the latest FxCop."

But nevertheless Suppress results from generated code option (project properties -> code analysis tab) for some reason does not preventing from code analysis for auto generated code of .edmx model.

Then I've found blog, which helped me solve this issue.




回答2:


I've used the /ignoregeneratedcode switch in the project that contained the auto generated code that I did not want FxCop to analyze.

Here is an MSDN FAQ about how to prevent FxCop 1.36 from firing warnings against auto generated code.




回答3:


You can skip assembly or rules(use checkbox in FxCop.exe to skip rules or assembly. Or even create your new rules for FxCop to suit your standard. FxCop also provide attributes which classes you do not want to verify.



来源:https://stackoverflow.com/questions/5006567/how-to-prevent-fxcop-from-analyzing-auto-generated-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!