24 January, 2011

Annoying static code analysis errors in visual studio 2010

I have just upgraded to VisualStudio 2010, and ran into these annoying warnings.

CA0503 : The CodeAnalysisRules property is deprecated. Use the CodeAnalysisRuleSet property instead.
CA0505 : The CodeAnalysisRules property will be ignored because the CodeAnalysisRuleSet property is defined.

In visual studio 2008 the only way of using a centralized rules file was to add the following line to the end of
our project file:

<Import Project="C:\Projects\Applications\Common\Rules\MyCompany.CodeAnalysis.Rules.targets"/>

In 2010 you can browse for an existing rules file from within the project options.
And it will store the rules file like this:

<CodeAnalysisRuleSet>..\..\Common\Rules\MyCompany.CodeAnalysis.ruleset</CodeAnalysisRuleSet>

If you have defined both, then you will get the CA503 and CA505 errors.
So in visual studio 2010, just remove the old style import tag.

No comments:

Post a Comment