Search code examples
c#.net-4.5stylecop

Disable all stylecop warnings for a specific C# class


I am working in an application and developing few classes for demo purpose. I know that these classes will be removed in future.

Is it possible to ignore all the stylecop warnings for those classes as I dont want to spent the time on those warnings?

I searched but found that I can only ignore via settings in stylecop( this will effect other classes too) or to some specific rule ( I just want to ignore all warnings).


Solution

  • Beginning with StyleCop 4.4.0, it is also possible to suppress all of the rules within a rule namespace, using a single suppression attribute. This is indicated by replacing the rule CheckID and rule name with a single asterisk. The following code example suppresses all of StyleCop's default documentation rules within the inner class. In this case, StyleCop would still flag a violation indicating that the outer class is missing documentation, but it would ignore all documentation rules for the inner class and its contents.

    public class OuterClass
    {
        [SuppressMessage("StyleCop.CSharp.DocumentationRules", "*")]
        public class InnerClass
        {
            public void MyUndocumentedMethod
            {
            }
        }
    }
    

    http://stylecop.soyuz5.com/Suppressions.html