This project is read-only.

some additional rules to consider?

Nov 28, 2010 at 11:11 PM

I have my own custom stylecop rules, which I'd written unit tests for, but unfortunately since moving companies, I'm struggling to get the unit tests working again, so when I saw StyleCop+, I thought I'd check it out.  While it provides some useful improvements, there are a couple of rules I would like to see included:

1) Avoid Abbreviated Character Variable Names, (e.g. blocking the use of X, tmp, etc.  Needed at least 4 characters to be acceptable.

2) Class Must Existing In File of Same Name, e.g. "SomeClass" must be in a file called "SomeClass.cs" - though resharper provides this sort of warning, but StylecCop MSBuild integration meant it would flag it up on our CI build server.

3) Methods Should not be more than 100 lines (although I'd be tempted to reduce this number further)

I think for now I'll stick with my "untested" ruleset for now, but will definitely keep an eye on StyleCop+ and consider switching in the near future.


Nov 29, 2010 at 4:31 PM
Edited Nov 29, 2010 at 4:31 PM

Hi Andy,

Thank you for your feedback!

All rules that you mentioned are very useful indeed and I will try to include them in StyleCop+.

Currently I am working on some other issues (and slight redesigning).
Probably after a few weeks I will try to implement some of your considerations.

Stay tuned!

Best regards,
Oleg Shuruev

Jan 6, 2011 at 11:23 AM

Good ideas! Thank you!

Ad 1) Maybe this is already covered by FxCop which uses a dictionary and also avoids misspelled upper/lower case: e.g. BarCode vs. Barcode, Filename vs. FileName etc.

Ad 2) I agree! Also the namespace and directory structure should be the same which is already covered by ReSharper.

Ad 3) YES!!! Maybe it would make sense to make the number of lines configurable (<100) ;-)

Best regards,
Harald-René Flasch (aka hfrmobile)

Jan 6, 2011 at 4:31 PM

Just wanted to point here that #3 has been implemented in StyleCop+ 0.11 release.

Yes, of course it is configurable.

Best regards,
Oleg Shuruev 

Jan 6, 2011 at 9:35 PM

Thank you, already installed (using StyleCop 4.3)

Btw, no method is longer than 100 lines in my projects :o)

(except in legacy code where the FormDesigner code is within #region in the same .cs file ...)

Kind Regards,
Harald-René Flasch (aka hfrmobile)

Jan 7, 2011 at 7:04 AM

You could try to reduce the maximum allowed number of lines to 20 (for example) and test how the rule works.

Will you share the result?
It is interesting because I have no expirience in intensive using of "branch for 4.3".

Thank you!

Best regards,
Oleg Shuruev

Jan 10, 2011 at 8:59 AM

The rule works fine for branch 4.3!

Btw, just have an idea for additional rules: Maximum number of methods, properties, fields etc. per class. This would help identifying so called "god classes" (

Best Regards,
Harald-René Flasch (aka hfrmobile)