8

Possible Duplicate:
How to suppress a StyleCop warning?

Currently I'm setting up StyleCop for our projects and I stumbled on one rule of StyleCop. It's about the SA1300 naming rule:

SA1300: namespace names begin with an upper-case letter: iCompanyName.

So my company starts with a lower-case letter. And various product names do also. Therefore, is there a possibility to add exceptions to this rule in the Settings.StyleCop file?

I'd like to prevent to write custom StyleCop rules using C#.

Thanks in advance for your replies.

edit: I realize I should have noted that I don't actually want to disable/suppress the StyleCop rule completely. I'd just like to make some exceptions on this naming rule.

Community
  • 1
  • 1
Herman Cordes
  • 4,628
  • 9
  • 51
  • 87
  • 9
    `my company starts with a lower-case letter` the easiest option is to switch to a company with style-cop compliant name. – Bala R Jul 05 '11 at 13:42

2 Answers2

5

The SA1300 rule is not configurable (at least in version 4.4). If you don't like its behaviour and don't want to disable the rule entirely, you will need to use a substitute custom rule. You might be able to find one available from a third-party such as the StyleCop+ project. If not, you're pretty much stuck rolling your own...

Nicole Calinoiu
  • 20,843
  • 2
  • 44
  • 49
  • Good suggestion to try the StyleCop+ project. However, doesn't really provide functionality to make naming rule exceptions. Guess I have to make my own rules, thought it should be possible within the config. – Herman Cordes Jul 05 '11 at 15:24
  • If you want the rule to be configurable, you could add a feature request at http://stylecop.codeplex.com/workitem/list/basic. Personally (particularly as an API consumer), I don't think that namespace casing should be allowed to deviate from this rule, but ymmv... – Nicole Calinoiu Jul 05 '11 at 15:49
  • 1
    Hi Monty. I am StyleCop+ author and, by its design, it offers extremely flexible naming rules. Different naming styles, prefixes, exceptions, abbreviations, complex words... this is all what StyleCop+ was created for. In your case, you could force, for example, all namespaces to be named as [PascalCase] OR "iYourCompany" (like an exception). Or, for example, [PascalCase] OR i[PascalCase] (i.e. allow any names starting with "i"). What I can agree about, that it may have lack of documentation - but it's being worked on. Feel free to contact me, I'll answer any questions with pleasure. Thank you! – Oleg Shuruev Jul 05 '11 at 20:17
  • 1
    @Oleg, thanks for your nice answer. I did gave it another shot and I managed to get it working the way I wanted it to!! Thank you very much. – Herman Cordes Jul 06 '11 at 19:22
  • Is it really not configurable? Warning stands "Remove the prefix or add it to the list of allowed prefixes.". Or the warning is wrong or there should be a list where a prefix can be added. **Where?** I could not find it anywhere. – juagicre Feb 29 '16 at 14:12
4

You can suppress the message on a case by case basis as described on the StyleCop site - http://stylecop.codeplex.com/wikipage?title=Rule%20Suppressions

Also, have a look at this question - How to suppress a StyleCop warning?

Community
  • 1
  • 1
devdigital
  • 34,151
  • 9
  • 98
  • 120