July 7, 2010 DevMeeting, Resharper 4 comments
July 7, 2010 DevMeeting, Resharper 4 comments
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.
June 25, 2010 Resharper No comments
Sometimes when you have few huge solutions opened performance of your PC is very critical and having Resharper over that is notable.
For our good luck with new versions of Resharper you could suspend it easily:
But going into menu is boring thing, so I think you would prefer to setup few hotkeys for that.
Basicly you will need to map Resharper_Suspend and/or Resharper_Resume. I bound those to “Ctrl+R, Ctrl+S” for Suspend and “Ctrl+R, Ctrl+R” for Resume.
Also, as I found over internet, JetBrains promise to have 5.1 being faster and without performance issues, but did not found any official words about this, just twits.
Personally I use Resharper Nightly Builds and enjoy them very much.
Hope this helps.
March 23, 2010 Resharper No comments
As you know with Resharper when you press “Ctrl+B” you navigate to the declaration of thing you are currently located on. But when you press that on double for example? In Visual Studio you are able to navigate to the metadata view, but Resharper provides 3 options: Object Browser, MetadataView and actual .Net Framework code. If you have no appropriate mscorlib.pdb Resharper will download it like on the picture below:
So finally you are able to see this code:
This is one of things why I love Resharper, no need to go for another tool like Reflector.