Archive for February, 2008

Talking ReSharper

Thursday, February 21st, 2008

This is not a kind of post that you’d recommend as a source of insight but it’s important nevertheless as we’d like to say a random thank you to all the people who have recently pushed ReSharper to the masses by sharing their positive experience in their posts - this, in particular, applies to:
 
Ben Hall for a prompt independent review of earliest R# 4.0 nightly builds
 
Matthew Cochran, who reviews code cohesion practices and recommends ReSharper for its set of refactorings
 
Casey Charlton for pointing out how responsive R# team members can be at times
 
As well as all of you who announced the advent of the life-giving R# 4.0:
 
Alex de Groot
Arjan Zuidhof
Chabster
Chris Alcock
Chris Brandsma
Darrell Russell
Darren Stokes
David Longnecker
Davy Brion
Einar Ingebrigtsen
Gabriel Lozano
George Barbu
Hadi Eskandari
Jan Van Ryswyck
Jeroen
Matthew Podwysocki
Oren Eini
Rinat Abdullin
Simone Chiaretta
Stefan Lieser
Steve
Steven Harman
Tim Boland
Will Asrari
 
and many others!

Technorati tags: , ,

ReSharper 4.0 Nightly Builds Available!

Friday, February 15th, 2008

Please read this and that before you start to moan proceed.
 
If you feel you’re ready, you can start downloading R# 4.0 nightly builds here.
 
And don’t forget the release notes!

Technorati tags: , ,

ReSharper in Detail: Reformatting Code

Sunday, February 10th, 2008

ReSharper can reformat an arbitrarily selected block of C# or VB.NET code, all code in the current file, all files in a directory, the current project, or even the current solution, according to options configurable in:
 

  • ReSharper | Options | Languages | C# | Formatting Style for C# code, or
  • ReSharper | Options | Languages | Visual Basic .NET | Formatting Style for VB.NET code.

 
Once the formatting settings are configured, you can share them with your fellow team members to ensure uniform code appearance.
 
Whenever you have a file opened in the editor, select a fragment that you want to reformat, or, alternatively, don’t select anything, in which case reformatting will apply to the entire file. Then launch Reformat Code in one of three ways:
 

  • Choose ReSharper | Code | Reformat Code on the main menu.
  • Press Ctrl + Alt + F (no default shortcut in VS scheme).
  • Choose Reformat Code in the context menu.

 

 
The Reformat Code dialog box (shown above) contains several formatting options:
 

  • Optimize ‘using’ directives removes redundant namespace import directives from the source code. Note that this option is disabled when you have a selection – even if it includes the imports section of your file.
  • Shorten references replaces fully qualified names with short names where possible by importing namespaces.
  • Remove redundant ‘this.’ qualifier deletes unnecessary this keywords (note that it doesn’t do the same for VB.NET keyword Me).
  • Reorder type members (for C# code only) reorders type members according to patterns specified in ReSharper Options | Languages | C# | Type Members Layout.

 
After you have reformatted your code, ReSharper saves the state of check-boxes for future use. Subsequently, you can even launch Reformat Code silently, without opening the dialog box, by pressing Ctrl + Shift + Alt + F (or Ctrl+E, F in the Visual Studio keyboard layout).
 
An additional advantage is that you can execute reformatting via Solution Explorer. For example, you can reformat a specific C# code file, or all such files in a project or entire solution. Just right-click the required node and choose Reformat Code….
 
Additional links:
 
Kyle Baley explains how to remove regions with the Reformat Code feature (C# only)
An example of how you can customize a type member layout pattern
Tips for using Reformat Code with aspx pages
Joe White’s detailed review of ReSharper’s reformatting tools

Technorati tags: , , , , ,

ReSharper in Detail: CamelHumps

Friday, February 1st, 2008

CamelHumps is a feature that identifies parts of compound names composed according to CamelCase, where each part starts with a capital letter (“hump”).
 
By default, it works in four navigation commands, namely Go To Type, Go To File, Go To File Member, and Go To Symbol, like this:

 
However, you should take an additional step to activate CamelHumps for the Extend/Shrink Selection (Ctrl + (Shift) + W, or Ctrl + Alt + Right/Left in the Visual Studio keyboard layout) and Next/Previous Word (Ctrl + Left/Right) navigation actions. To do that, choose ReSharper | Options | Environment | Editor and select Use CamelHumps.
 
From now on, CamelHumps is switched on, and jumping to next/previous word works in a slightly different manner. Specifically, when you press Ctrl + Left/Right, the caret moves to the next/previous uppercase character in the current word, and only after that, it moves on to the next/previous word.
 
Extend/Shrink Selection commands are also affected by CamelHumps. Suppose that the caret is in the middle of a compound word with several parts that begin with uppercase letters:

If CamelHumps is switched on, pressing Ctrl + W for the first time selects the current part of the word:

It’s only after pressing this keystroke for the second time that you can select the whole word:

All subsequent keystokes are processed as usual.
 
In addition, ReSharper provides four actions for using CamelHumps locally when the global option (Use CamelHumps) is switched off:
 

  • ReSharper_HumpNext - move caret to next hump/word
  • ReSharper_HumpPrev - move caret to previous hump/word
  • ReSharper_HumpNextExtend - expand selection to next hump
  • ReSharper_HumpPrevExtend - expand selection to previous hump

 
Of course, you can assign individual shortcuts to these actions in the Visual Studio Options dialog box (Tools | Options | Environment | Keyboard).
 
Note that both HumpNextExtend and HumpPrevExtend only work in a linear fashion, without additional functionality of Extend/Shrink Selection.

Technorati tags: , , , , , ,

R# 4.0 EAP - FYI

Friday, February 1st, 2008

Sad but true: R# 4.0 EAP is late. According to our updated schedule, it’s going to start before February 15th.
 
See Ilya Ryzhenkov’s latest blog entry for details.

Technorati tags: , ,