July 7, 2010 DevMeeting, Resharper
July 7, 2010 DevMeeting, Resharper
Resharper
Resharper is code refactoring and productivity extension to Visual Studio. While you are typing it analyzes code and highlights errors, suggests quick-solutions and hints on code completion. It allows you generate lot of code, perform code clean-up and do different refactorings. Resharper saves your time.
My reasons why to use Resharper
Why not to use Resharper (*)
Developer’s meeting
Finally I’ve decided to provide developer’s meeting on Resharper. Long time ago (1.5 years) we had developers meeting provided for our team (about 50 people) on regular bases. We’ve lost that process because guy providing those has moved to Austria. Now we have those meetings quite rarely, mainly me trying to provide a lot of them. Help me, post some feedback here.
What you may need to be prepared for such kind of meeting?
It is obvious that we could not have PowerPoint pretension for this topic, so you will need write code illustrating Resharper. Second thing is that you should have some scenario to proceed with. You cannot simply go and create code on the flow, because it may happen that you will fall in wrong corner. So this post represents short plan for meeting and kick-off tutorial for my co-workers if they will like my talk.
Plan Of Attack
Introduction
I would need give some general definition to what Resharper is and show where from we can download it.
As it is recommended good approach is to know your auditory. Few questions? Ask who knows some hotkey, say Ctrl+Alt+G. This is very common hotkey, but not as much as Alt+Enter and answer for this question should allow you see how deeply they know Resharper and how quick you should be with core functionality in Resharper.
SetUp Resharper
Once you have installed Resharper, you may go and change keyboard layout under Resharper->Options->Visual Studio Integration
As I figured out almost each active user of Resharper uses IntelliJ IDEA keyboard layout and I would recommend it for you.
Besides, you may leave some of the VS native shortcuts – first time you are going to use F12 for example it will re-ask you if you want use Resharpers (navigate to error) or VS (go to definition) one. This way you may save most commonly used keys from VS. You can download keymap pdf file from here.
Also it is possible to save all of your configuration in xml file and share with others.
Damn It! Let’s write some code.
KeyboardJedi
For the meeting you will need demonstrate hot-keys you are pressing. For this I’m using KeyboardJedi by Roy Osherove.
On following screenshot we can see that I’ve pressed Shift+F6 and got renaming dialog box. Please note KeyboardJedi at the left.
I renamed file to be Calculator.
Introducing Alt+Enter
This hotkey is the most commonly used. It shows available quick-fixes and context actions. Showing how we can change visibility of class with this. So guys start with learning this hotkey!
Templates usages
Pushing Members Up and Down
We even could mark something as abstract when pushing down.
So this gives us change in 3 different files simultaneously.
public abstract class OperationBase : IOperation
public class OneOperandOperation : OperationBase
Learning Generating Code (Alt+Ins)
Generating constructor, properties, auto-properties, surrounding with some template (Ctrl+Alt+Ins)
Scenario: method needs to be thread-safe, so we surround it with locking (Ctrl+Alt+Ins), and we are refactoring with introducing object lock, then we refactor with introducing field (Ctrl+Shift+R).
Scenario: method has lot of code so we use extract method refactoring (Ctrl+Alt+M).
Navigation (Ctrl+Alt+G)
Navigation is one of the features of resharper that is very important in huge complex solutions. And that is one of my favorite ones. JetBrains did a lot of improvements in navigating through solution.
From any part of code you could easily navigate to whatever you want by pressing: Ctrl+Alt+G.
Navigate to type (Ctrl+N)
When showing this also good to illustrate on big solution, also mentioning about camel cases. So in picture below, you could see that I just typed “CDS” and I’m able to see few different classes that match what I need.
Scenario: Navigation to declaration, implementation and so on.
Navigation to class members (Ctrl+F12).
Unit Testing
Resharper supports unit testing frameworks, so it could easily work with NUnit as well as MSTests in one solution.
Scenario: Writing UT using live template for test method, debugging UT imitating TDD, creating shortcut for UT run.
Live template
When showing unit testing capabilities we may show how to create template for unit test, or some special kind of UT.
Few other scenarios
Links
Everything needed could be found from this page: http://www.jetbrains.com/resharper/
P.S. Items marked with (*) were added after I had posted this article.
Markdown | Result |
---|---|
*text* | text |
**text** | text |
***text*** | text |
`code` | code |
~~~ more code ~~~~ |
more code |
[Link](https://www.example.com) | Link |
* Listitem |
|
> Quote | Quote |
Why did you not mention that ReSharper is commercial product?;)
DixonD, thanks. I changed my post a bit. See (Why not to use Resharper).
Hey :) It was really cool to see all that stuff with Very Hot Keys – yami-yami :)
I'll say – "Excellent post", it is good to see all important information combined in "short explanation". Especially for me – addicted to ReSharper :) Well, aren’t we all?
Julian, thanks for the comment. I will keep doing the best to deliver interesting stuff & my knowledge to all of you.