views:

675

answers:

7

I'm in the middle of an ASP.NET MVC project and recently installed the free trial of ReSharper 4.5. Immediately I realized the benefits, simply because of the refactoring it wanted me to do.

Things like inverting if statements to reduce nesting, changing some of my if/else statements that were returning Views to ?/?? operators - drastically reduced the number of lines of code in my app.

The capability of performing a null reference check from a single click, removing unused directives/variables or removing redundant code (calling .ToString() when it wasn't necessary). Or, that it can see into my views to let me know I'm accessing a property that no longer exists, makes solution-wide renames more thorough... really saves a lot of time.

But I get the feeling that I'm only seeing the tip of the iceberg. So I ask this:

What do YOU use ReSharper for? Anything beyond the immediate benefits I described above?

A: 

i use resharper for:

  1. Creating fields automatically
  2. Generating classes and methods (while doing TDD)
  3. Automatically adding namespaces
  4. Finding usages
  5. Solution wide background compilation
  6. templates to standardize conventions among a team.
ooo
Ah yes, automatic fields, auto namespacing...What sort of templates do you use?
Chad
we standardize on conventions with variables (member and argument variables). also there are addin like agent smith to have resharper show errors when you dont follow other rules as well
ooo
Nice.. I suppose since I'm developing alone at the moment that the templates could simply be used as code snippets of sorts?
Chad
+1  A: 

It can be used to keep the headers of each file up to date in an open source project. By headers I mean license text.

Scott Whitlock
+1  A: 

I used a really early version and found that it became really annoying when you were typing and the silly thing paused while it loaded the intelisense.

No key strokes were lost but the pause annoyed me no end.

Has this been fixed or not?

So at the moment my answer is I don't.

griegs
yes.. much better in 4.5
ooo
ah good. i might re-evaluate it for this place then. thanks [me]
griegs
+3  A: 

ReSharper provides a huge set of tools beyond the simple refactorings it suggests. In addition to providing additional code auto-formatting capabilities, ReSharper provides an integrated unit test runner that works with all of the known unit-test frameworks (such as NUnit, MBUnit, and my personal favorite, XUnit.NET). ReSharper also provides a very powerful template-based code generation platform that can improve your productivity by leaps and bounds.

For a full list of all the capabilities ReSharper can offer you, check here:

http://www.jetbrains.com/resharper/features/index.html

jrista
Could someone explain what the down vote was for?
jrista
Oh man, the screenshot of the Code Templates link shows a join "snippet" for LINQ. Very cool... gonna have to get used to this.
Chad
About the down vote, no idea... I up-voted it. :D
Chad
@Chad: ReSharper is definitely THE programmers toolkit to get. It completely changed the way I write code...and I've been writing code since I was 8. Enjoy the wonderful new world of ReSharper! :D
jrista
+3  A: 

What don't I use it for is more like it. Here's a shortlist of my most often-used shortcuts:

  • Running unit tests. Their GUI unit test runner is awesome (sort by project/namespace is great), and I shortcut Alt+X to run a test.

  • Adding a class for unit tests, templated out with live templates

  • Multiple custom livetemplates for filling in code, especially complex attributes

  • Weeding dead code on our enterprise codebases

  • Converting properties to auto-properties

  • Combining variable declarations with their setup code

  • Making methods static that can and should be static

  • Looking at the pre-compilation errors/warnings bar saves me tons of time

  • StyleCop for Resharper puts all my styling warnings inline for me.

Pretty much most of these are done with just Alt+Enter. The time saved is incalculable.

womp
+2  A: 

Geez, where to begin?

  • Refactoring.
  • Code formatting.
  • Code templates.
  • Marker bar (the red/yellow/green stripes in the sidebar to show code warnings).
  • Highlighting of unused code.
  • Code generation.
  • Shortcuts to save typing (e.g. Alt+Enter to remove unneeded braces, change visibility, etc.)
  • Code browsing. (Find References, Class Hierarchy, etc.)
  • Unit testing.
  • I could go on...

If you want a thorough overview of what ReSharper can do, check out my blog series, 31 Days of ReSharper. It's missing the latest and greatest features (it was written for R# 2.5), but it shows a lot of ReSharper in action.

Joe White
Nice blog series... ty for sharing.
Chad
A: 

If you're using ASP.NET MVC, you might be interested in the new Resharper 5 beta, it adds some nice features specifically.

  • Ctrl + click navigation, find usages and refactoring from 'magic strings' ActionLink to Controllers/Actions

  • Ctrl + click navigation find usages for your Views referenced in your controller actions, and to the partial views referenced in your views

  • Displays errors (even solution wide) when your ActionLink references a non-existing Controller/Action and allows you to automatically create stubs for it

Zidad
We also provide Intellisense for Actions, Controllers, User Controls, etc.
Hadi Hariri