Is it possible to allow specific names for namespaces

Jul 24, 2011 at 3:22 AM

At the moment StyleCop+ reports a violation for the namespace of my project. The project is named NSarrac and the namespace rule is pascal casing so it makes sense that StyleCop+ reports an error. The question now is how do I tell it that I want to allow my project name to be used as a namespace element?

Thanks

Coordinator
Jul 25, 2011 at 2:12 PM
Edited Jul 25, 2011 at 2:13 PM

Hi,

1. The most typical case is that you just add another one "variant" for naming namespaces.
In a result, your "Namespace" setting will look like this:

$(AaBb)
NSarrac

This will allow you using such namespaces as NSarrac.Engine.Core or System.Collections.NSarrac.

 

2. The more advanced scenario is that you understand that you want use NSarrac everywhere as a part of your method name or property name, or class name, etc...
For example, GetNSarracProduct() or NSarracServiceType

In this case you need to tell StyleCop+ that you want it to always consider NSarrac as a whole word.
Changing "Complex words" setting will solve this:

StyleCop FxCop NSarrac

As I said before, this will affect all names in your project, not only namespaces.

Please feel free to let me know in case of any problems.
Thank you!

Best regards,
Oleg Shuruev

Aug 3, 2011 at 9:39 AM

Thanks. I'll go with the first option given that I'll only be using it for namespaces.

Coordinator
Aug 3, 2011 at 11:47 AM

You're always welcome with new use-cases or useful ideas!

Best regards,
Oleg Shuruev