I'm building several ruleset files with all the same rule IDs but ascending levels of included MS rulesets and increasing severity of the Action for some of the rules. The problem I'm having is that VS2010 is telling me there's an error loading my FXCop_VS2010_HIGLevel2.ruleset file while the FXCop_VS2010_HIGLevel1.ruleset loads fine. They essentially look the same:
FXCop_VS2010_HIGLevel1.ruleset
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="HIG VS2010 Code Analysis Rules Level 1" Description="These rules expand on the basic design guideline rules to maximize the usability and maintainability issues that are reported. Extra emphasis is placed on naming guidelines. Consider including this rule set if your project includes library code or if you want to enforce the highest standards for writing maintainable code." ToolsVersion="10.0">
<Include Path="BasicCorrectnessRules.ruleset" Action="Default" />
<Include Path="SecurityRules.ruleset" Action="Default" />
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1000" Action="None" />
<Rule Id="CA1001" Action="None" />
...
<Rule Id="CA2239" Action="Warning" />
<Rule Id="CA2240" Action="None" />
<Rule Id="CA2242" Action="None" />
<Rule Id="CA2243" Action="None" />
</Rules>
</RuleSet>
FXCop_VS2010_HIGLevel2.ruleset
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="HIG VS2010 Code Analysis Rules Level 2" Description="These rules expand on the basic design guideline rules to maximize the usability and maintainability issues that are reported. Extra emphasis is placed on naming guidelines. Consider including this rule set if your project includes library code or if you want to enforce the highest standards for writing maintainable code." ToolsVersion="10.0">
<Include Path="BasicCorrectnessRules.ruleset" Action="Default" />
<Include Path="BasicDesignGuidelineRules.ruleset" Action="Default" />
<Include Path="SecurityRules.ruleset" Action="Default" />
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1000" Action="Warning" />
<Rule Id="CA1001" Action="None" />
...
<Rule Id="CA2239" Action="Warning" />
<Rule Id="CA2240" Action="None" />
<Rule Id="CA2242" Action="None" />
<Rule Id="CA2243" Action="None" />
</Rules>
</RuleSet>
You can see that they're essentially the same. Level 2 adds the BasicDesignGuidelineRules.ruleset and changes the actions on some rules (i.e. CA1000 goes from "None" at Level 1 to "Warning" at Level 2).
This is the error I get from VS2010 when I put the Level 2 ruleset file into the Static Analysis Tools\Rule Sets folder:
Any ideas why this is happening? I went through the Level 2 XML line by line and I ran a file compare to the Level 1. The only differences are what I expected. I used Notepad++ to display non-printing characters and nothing other than CRLF in the appropriate places. I'm stumped.
As you privided in your comment, you said the problem got resolved after changing the Actions from CriticalWarning
to Warning
, and CriticalError
to Error
.
This behaviour is explained here: http://msdn.microsoft.com/en-us/library/dd380626.aspx
You must have mistaken the action for the MessageLevel property
in custom rules XML-files. In this property you can set the following values: