|
Hi all !
I have some problem to get Microsoft StyleCop to pick a new rule up. The new rule is not shown in the Settings.
I just did as said in the documentation _StyleCopSDK.htm
The assembly is compiled without errors.
AccessModifiers.cs and AccessModifiers.xml below
I'm using VS10 with SP1 and SC 4.7.17
Thanks for help in advance
--------------------------------------------------------------------------------------
namespace AccessModifiers
{
// Checks for the presence of access modifiers on all elements.
[SourceAnalyzer(typeof(CsParser))]
public class AccessModifiers : SourceAnalyzer
{
public override void AnalyzeDocument(CodeDocument document)
{
CsDocument csdocument = (CsDocument)document;
if (csdocument.RootElement != null && !csdocument.RootElement.Generated)
{
csdocument.WalkDocument(
new CodeWalkerElementVisitor<object>(this.VisitElement),
null,
null);
}
}
private bool VisitElement(CsElement element, CsElement parentElement, object context)
{
// Make sure this element is not generated.
if (!element.Generated)
{
// Flag a violation if the element does not have an access modifier.
if (!element.Declaration.AccessModifier)
{
this.AddViolation(element, "AccessModifiersMustBeDeclared");
}
}
return true;
}
}
}
----------------------------------------------------------------------------------------------------------------
AccessModifiers.xml
-----------------------------
<?xml version="1.0" encoding="utf-8" ?>
<SourceAnalyzer Name="Extension">
<Description>
This is my first rule ever done.
</Description>
<Rules>
<RuleGroup Name="MLOYRules">
<Rule Name="AccessModifiers" CheckId="MY1000">
<Context>What ever it is !!.</Context>
<Description>Detail descrition.</Description>
</Rule>
</RuleGroup>
</Rules>
</SourceAnalyzer>
|