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.
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();
how can i trip this FxCop Rule?
Did you analyze not with Visual Studio Code Analysis, but with the stand-alone FxCop?
If so, your code isn't checked because FxCop doesn't support the AvoidCallingProblematicMethods rule.
To be more exact, FxCop doesn't contain Reliability and Maintainability rules. The AvoidCallingProblematicMethods rule is categorized as a Reliability rule.
You can see a comparison table of code analysis rules supported by VS Code Analysis and FxCop from here.
UPDATE
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.
- Backup assemblies in FxCop Rules
directory ("%PROGRAMFILES%\Microsoft
FxCop 10.0\Rules" by default).
- Copy assemblies in
"%PROGRAMFILES%\Microsoft Visual
Studio 10.0\Team Tools\Static
Analysis Tools\FxCop\Rules" to FxCop
Rules directory, except
DataflowRules.dll (FxCop can't load
rules from DataflowRules.dll).