views:

63

answers:

4

Got a style conflict between StyleCop and Resharper. Stylecop 1303 says that const vars should start uppercase and I agree. Resharper says OK for class-wide const declarations, but when using a const in a local (e.g. method) scope, Reshaper doesn't approve and wants to make everything camelCasing.

Of course no problem to disable this rule in R#, but what could be the reason behind this rule? Anyone any thoughts?

A: 

I think StyleCope is using the case to distinguish between class and method scope.

ShellShock
Huh? This would mean that all class-scoped fields would be UpperCamelCase as well...
Thomas Weller
Don't diss me--I didn't make the rules.
ShellShock
You didn't make the rules, of course... But you should think about them anyway ;-)
Thomas Weller
A: 

I'm sure almost everyone has thoughts on that, and those are seldom in sync. Find your flavor and stick with it. Re# and the like are suggestions. You and your coworkers should agree on something, that is most important.

danijels
A: 

I'd stick to the R# interpretation in this case (on local scope, everything should be lowerCamelCase).

It's largely a matter of habit, because I'm usually starting with a variable, and after I've finished the method, I might change the var to a const, if the respective R# smart tag recommends this to me.

But as pointed out, the important thing is to be consistent across the team...

Thomas

Thomas Weller
While I agree, the consistency is the important thing, using StyleCop implies that you've chosen to follow the StyleCop rules. This means you're better off changing Resharper configuration rather than disabling rules.
Simon Steele
Huh? There is no such thing as 'StyleCop rules'. StyleCop is just a configurable and extensible text-checking tool that comes preconfigured with _Microsoft rules_. And anyway: What brings you to the opinion that StyleCop should be 'right' and R# should be 'wrong'?
Thomas Weller
@Thomas Weller Many decisions on code format in StyleCop can be seen as arbitrary. Some have good reasoning and some are just a case of picking one style and sticking to it. Most rules are not configurable for one way or the other, so choosing Resharper's default rather than StyleCop's means that you will not have StyleCop checking your code is consistent any more. The point of using StyleCop is to ensure code all looks the same and to avoid "which is best" arguments. It's not that StyleCop is necessarily better than Resharper, just that it's easier to use StyleCop for enforcement.
Simon Steele
+1  A: 

If you download Stylecop for Resharper then it comes with a Resharper settings file that will fix this for you. It's also a great way to get Resharper to help you with Stylecop compliance:

http://stylecopforresharper.codeplex.com/

Simon Steele
I already have that running :) But still this conflicts.
Marcel de Kleine
@Marcel de Kleine Did you import the settings file? It doesn't happen automatically when you install the plugin. Regardless, I'd still stick with the StyleCop settings - that's what you use StyleCop for. If you have imported that file, it might be worth filing a bug on S4R to let them know there's something else they need to override :)
Simon Steele
I imported the settings file but still have the conflict so will do as you suggested so they can fix this.
Marcel de Kleine