Custom rules "repository" for alternative style guidelines?

Jun 27, 2011 at 9:04 PM

Is there any sort of repository for community-made custom rules for StyleCop? I'm looking for some implementations of what I presume to be common alternate style guidelines. I (and my fellow developers) would rather I find some written by people who know what they're doing, if that's feasible, than write them in-house.

For example, our long-standing coding guidelines make a distinction between opening/closing parentheses on method calls vs. control flow and declaration, so we would need to write the following:

public void Load ( string filename )
	if ( !File.Exists(filename) )
		throw new ArgumentException("Invalid or non-existant file requested.""filename"); = XElement.Load(filename);
	logger.InfoFormat("Load(): Loaded attribute mappings from disk.");

Unfortunately, StyleCop's rules SA1003, SA1008 and SA1009 complain about the method declaration and if statement. I don't want to just disable those rules, as we don't want whitespace inside the method calls, but the rules aren't smart enough to tell the difference. We have a similar policy (unfortunately borrowed intact from C/C++) of all constant values being UPPER_CASE to distinguish them from static readonly fields.

Is this something that exists somewhere, or should I just start cranking these out myself?



Jun 28, 2011 at 3:19 AM

Hi Mike,

There is no common repository for custom rules.
In fact, there is no so much custom rules which were made "public" (I know 3 or 4).
I guess most of custom rules are being written in-house and not even published ever.

I also can't tell anything about your feature with parenthesis, but StyleCop+ custom rules definitely can help with naming for constant values (and not only them).

Best regards,
Oleg Shuruev