I'm trying to migrate our custom FxCop (= Code Analysis) rules from Visual Studio 2010 to Visual Studio 2012.
So far, they work fine except for one thing: their name is blank in the results window (View
-> Other windows
-> Code Analysis
), only the CheckId
and the Resolution
show up, while the name is shown for Microsoft's rules:
What is strange, is that the name is visible in the ruleset editor:
What is wrong with my rules?
Details
Here is how both rules show up in MSBuild's output (there's something fishy there, but I don't understand why I have a different message):
6>c:\Users\Me\MySolution\MyProject\Program.cs(15): warning : CA1804 : Microsoft.Performance : 'Foo<T>.SomeMethod()' declares a variable, 'z', of type 'int', which is never used or is only assigned to. Use this variable or remove it.
6>MSBUILD : warning : CF1001 : CustomRules.ThreadSafety : The public Public Field "Tests.Program.Foo" must be preceded of readonly
Here is the rule declaration in the XML file for my rule:
<?xml version="1.0" encoding="utf-8" ?>
<Rules FriendlyName="CustomRules">
<Rule TypeName="PublicFieldsMustBeReadonly" Category="CustomRules.ThreadSafety" CheckId="CF1001">
<Name>Public Fields must be readonly or must be replaced with a Getter/Setter Method.</Name>
<Description>Public Fields must be readonly or must be replaced with a Getter/Setter Method.</Description>
<GroupOwner>MyCompany</GroupOwner>
<DevOwner>Me</DevOwner>
<Owner>Me</Owner>
<Url>http://example.com</Url>
<Resolution>The public Public Field "{0}" must be preceded of readonly</Resolution>
<Email>my@email.com</Email>
<MessageLevel Certainty="100">Warning</MessageLevel>
<FixCategories>Breaking</FixCategories>
</Rule>
</Rules>
And here is the rule declaration in the XML for Microsoft's rule.
<Rules FriendlyName="Performance Rules">
<Rule TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804">
<Name>
Remove unused locals
</Name>
<Description>
Remove locals that are not used or are only assigned to in method implementations.
</Description>
<Url>
@ms182278(VS.100).aspx
</Url>
<Resolution>
{0} declares a variable, {1}, of type {2}, which is never used or is only assigned to. Use this variable or remove it.
</Resolution>
<Email />
<MessageLevel Certainty="95">
Warning
</MessageLevel>
<FixCategories>
NonBreaking
</FixCategories>
<Owner />
</Rule>
</Rules>