code
vanced
Advanced solutions in .NET
Search
Include comments in search
Talks
Archive
About
Say Of The Day
Software gets slower faster than hardware gets faster.
-
Niklaus Wirth
Tags
agile
algorithms
api design
aspnet mvc
bla-bla-bla
c#
knetlik
metrics
mocking
moq
mvccontrib
ndepend
ninject
nmock2
performance
pex
productivity
rants
resharper
rhino mocks
typemock
unit testing
visual studio
whysharper
Medals
Blogroll
Mads Kristensen
Eric Lippert
Joel Spolsky
Dimitri Glazkov
Lean Thinking
Eldar Musaev (russian)
Steve McConnell
<< Estimation, The second kind of
|
Test failure diagnostics in mocking frameworks >>
Resharper presentation
July 25, 2009 17:00
The other day your humble correspondent conducted a two hours training: Resharper 4.5 overview
[1]
.
Here's nice a part of it. It captures 3 routine tasks we developers do extremely often:
Code completion
Minor refactorings
Moving code
Code Completion.
Resharper provides quite a few features for this small task
[2]
.
1.
If you just want
complete anything "visible from here"
- use
Symbol Completion
(
Ctrl+Space
by default) as on the examples below: they capture the moment when the shortcut
was just hit
.
2.
But if
you really know
what
you need and don't want to spend too much time going through a big dropdown - use
Smart Completion
(
Ctrl+Alt+Space
by default)
. Look at the example below:
the shortcut was
just hit and the dropdown contains
only items that
match
CustomerOrder
(as
ProcessCore
takes
it as a parameter).
3.
If you're going to use a type that is not imported yet,
Import Symbol Completion
is your friend (
Shift+Alt+Space
by default). It displays
everything
that matches a given prefix - that's especially germane if the type name is long...
with Resharper, you can just type the capital letters.
What if you need
ListViewVirtualItemsSelectionRangeChangedEventHandler
,
a
.NET type with the longest type name
? 53 characters. Phew!
Now look at the example below, it captures the moment when the shortcut
was just hit. Marvelous.
4.
If you want to insert
brackets, semicolons and other stuff and get directly to the place where you can start typing the next statement - use
Complete Statement
(
Ctrl+Shift+Enter
by default).
Say, if you'd type
public void Test(int count, string details
and hit the shortcut, Resharper will insert the closing parenthesis, put curly brackets and position the caret for you:
Then if, while in the method body, you'd type an expression - say,
string name = "foo"
and hit
the shortcut, Resharper will complete the semicolon and move you to the next line.
Minor Refactorings.
Quite often you need to apply a small local refactoring: invert
if
statement, replace
var
with explicit type, check a parameter for
null
, etc, etc. Resharper calls them
context actions
and once you step on a place where a context action can be applied, you see a yellow light bulb
.
Default shortcut is
Alt+Enter
- just hit it or click on the bulb to get a handful of refactoring options. Look at the examples below (
vertical
bold
yellow lines represent cursor positions).
Moving Code.
From time to time, the code needs to be moved around.
One line (or piece of code) might need to be put above the other, xml tags or attributes may need to be reordered. Usually it's done by copying the stuff to the clipboard, removing it and pasting it into the right place.
But I bet you'd like the Resharper way. While standing on the piece you want to move, hit
Ctrl+Shift+Alt
and use
up/down/left/right
arrows to move it as you need.
Footnotes.
The slides available
here
, other than that it was mostly code-n-talk stuff.
Look at
my previous Resharper post
for more details on code completion.
Comments are closed