StyleCop vs ReSharper and general coding-style questions

Viewed 10195

Just found StyleCop, looks like something worth using for my projects. Then I found out you could use it with ReSharper (a tool I've also never used). So I downloaded ReSharper, as well as StyleCop for ReSharper. I'm just a bit confused about it, though:

  1. With just StyleCop installed (no ReSharper), I get yelled at for referring directly to private variables in code-behind. It wants me to instead do this.variable. Alright, fine.

  2. If I use just ReSharper, it tells me to remove all of the 'this' calls I just added. Which one is better?

  3. If I use ReSharper + StyleCop for ReSharper, it now tells me to add 'this' to all private member references (just like StyleCop did all by itself). However, now it also wants me to add 'this' to all of the controls I'm referencing from the .aspx page (i.e., Label.Text = this.variable -> this.Label.Text = this.variable).

I'm so confused. What is the best standard to follow? Or am I just fine doing it the way I am now (Label.Text = variable)?

3 Answers

Sorry when working on a team it all comes down to understanding the politics; after all, we work to get paid!

If the person that decided your next pay raise uses StyleCop, then you should always include the “this.” likewise if the boss uses ReSharper you should do what ReSharper says.

There are a lot more important wars to win this, e.g. 10,000 line classes, over sized method

If you are luckly enough to decide what tools (and coding standards) are used yourself, then I would just choose ReSharper and read the “clean code” book.

Related