问题描述
我测试的FxCop自动化和要验证它是筛选和捕捉一定的规则。我想打一个DLL,它会触发AvoidCallingProblematicMethods错误的FxCop。
I am testing FxCop automation and want to validate it is screening and catching certain rules. I want to make a dll that will trigger the AvoidCallingProblematicMethods error in FxCop.
我有以下的code,但它不触发AvoidCallingProblematicMethods规则可言。我究竟做错了什么?
I have the following code but it is not triggering the AvoidCallingProblematicMethods rule at all. what am i doing wrong?
// use one of the listed unsafe methods to create a problematic method
// http://msdn.microsoft.com/en-us/library/bb385973.aspx for list of offending methods
GC.Collect();
我怎么能启动此的FxCop规则?
how can i trip this FxCop Rule?
推荐答案
你分析不使用Visual Studio code分析,但与独立的FxCop?
Did you analyze not with Visual Studio Code Analysis, but with the stand-alone FxCop?
如果是这样,你的code没有被选中,因为FxCop的不支持AvoidCallingProblematicMethods规则。
If so, your code isn't checked because FxCop doesn't support the AvoidCallingProblematicMethods rule.
要更准确,FxCop的不含可靠性与维修规则。该AvoidCallingProblematicMethods规则归类为一个可靠的规则。
To be more exact, FxCop doesn't contain Reliability and Maintainability rules. The AvoidCallingProblematicMethods rule is categorized as a Reliability rule.
您可以看到code分析规则由VS code分析的FxCop支持的比较表,从这里。
You can see a comparison table of code analysis rules supported by VS Code Analysis and FxCop from here.
更新
正如您将在佩德罗的评论看,你可以在使用的FxCop这个规则,如果复制VS2010 code分析规则的FxCop规则目录。
As you will see in Pedro's comment, you can use this rule in FxCop, if you copy VS2010 code analysis rules to FxCop Rules directory.
- 在备份中的FxCop规则组件目录(为%ProgramFiles%\微软FxCop的10.0 \规则默认情况下)。
- 复制的组件为%ProgramFiles%\微软的Visual工作室10.0 \团队TOOLS \静分析工具\ FxCop的\规则的FxCop规则目录中,除了DataflowRules.dll(的FxCop无法加载从DataflowRules.dll规则)。
- Backup assemblies in FxCop Rulesdirectory ("%PROGRAMFILES%\MicrosoftFxCop 10.0\Rules" by default).
- Copy assemblies in"%PROGRAMFILES%\Microsoft VisualStudio 10.0\Team Tools\StaticAnalysis Tools\FxCop\Rules" to FxCopRules directory, exceptDataflowRules.dll (FxCop can't loadrules from DataflowRules.dll).
这篇关于怎么给你codeA AvoidCallingProblematicMethods异常被拿起的FxCop?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!