NikolaiDante
NikolaiDante

Reputation: 18649

Installing Custom StyleCop Rule

In starting to create a custom StyleCop rule I have followed the instructions on the Visual StyleCop Github.

• I've created a class, MyStyleCopRules.cs:

[SourceAnalyzer(typeof(CsParser))]
public class MyStyleCopRules : SourceAnalyzer
{
    public override void AnalyzeDocument(CodeDocument document)
    {
       ...

• Added an XML document, with the build action set to EmbeddedResource, called MyStyleCopRules.xml:

<?xml version="1.0" encoding="utf-8" ?>
<SourceAnalyzer Name="My StyleCop Rules">
    <Rules>
      <Rule Name="Fully Qualified Using Statements" CheckId="IS0001">
        <Context>Using statements must be fully qualifed.</Context>
        <Description>Fires when using statements are not fully qualifed.</Description>
      </Rule>
    </Rules>
</SourceAnalyzer>

Other possibly pertinent facts:


I don't see the rules when I open the Settings.StyleCop file, nor do I see any indication that they run with Visual Studio.

enter image description here


What have I missed?

Upvotes: 2

Views: 2505

Answers (1)

NikolaiDante
NikolaiDante

Reputation: 18649

The Fully Qualified Using Statements needs to have no spaces in it.

Namely:

<?xml version="1.0" encoding="utf-8" ?>
<SourceAnalyzer Name="My StyleCop Rules">
    <Rules>
      <Rule Name="FullyQualifiedUsingStatements" CheckId="IS0001">
        <Context>Using statements must be fully qualifed.</Context>
        <Description>Fires when using statements are not fully qualifed.</Description>
      </Rule>
    </Rules>
</SourceAnalyzer>

Upvotes: 1

Related Questions