This project is read-only.

Cant import Custom Rules

Nov 25, 2011 at 2:48 PM


I´ve tried to import my customs rules, but it still don´t work. 

Here are my files "CustomRule.cs" and "CustomRule.xml": 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StyleCop.CSharp;
using StyleCop;

namespace CustomStyleCopRule
    public class CustomRule : SourceAnalyzer
        public override void AnalyzeDocument(CodeDocument document)
            Param.RequireNotNull(document, "document");
            CsDocument document2 = (CsDocument)document;
            if ((document2.RootElement != null) && !document2.RootElement.Generated)
                AddViolation(document2.RootElement, "MyCustomRule", new object[0]);

<?xml version="1.0" encoding="utf-8" ?>
<SourceAnalyzer Name="Custom Rules">
    Custom rules added to analyzer.
    <RuleGroup Name="Custom Rules Group">
      <Rule Name="MyCustomRule" CheckId="CR0001">
        <Context>This is a custom rule.</Context>
        <Description>This is a custom rule description.</Description>

The target-Framework is 3.5 and the xml file is marked as "Embedded Resource". I copy the .dll in the install folder of StyleCop.
Thanks for help!

Nov 30, 2011 at 4:10 PM


I could help you if you just shared (via email, dropbox, or in any other way) your entire project (or solution).

Best regards,
Oleg Shuruev

Nov 30, 2011 at 5:52 PM


can you give me an mail address, so I can share my Dropbox folder?


Dec 4, 2011 at 10:08 AM
Edited Dec 4, 2011 at 10:09 AM

Thanks for the help. I will implement the recommendations and hope that everything works.