| All blog entries are the opinions of the author and do not necessarily reflect the opinions of their employer. All the code presented is for explanation and demonstration purposes only. Any damages incurred to your site and/or data are not the responsibility of the author. Every effort is taken to ensure the code properly compiles, however sometimes there are some hiccups and you might be required to do your own debugging. |
|
|
Are you looking to get more out of Visual Studio? Do you use a special refactoring tool?
Jan
15
Written by:
Thursday, January 15, 2009 11:25 PM
Are you looking to get more out of Visual Studio? Do you use a special refactoring tool or are you like most people (IMHO) and just use what Visual Studio gives you? F2 to rename is the easiest refactoring feature to use, but the others aren’t so straight forward. Most of the time it’s just easier to do the other refactoring tasks by hand instead of trusting Visual Studio.
Well that’s all going to change! After watching a cool tips’n’tricks vid for Visual Studio I found out about a cool FREE tool called CodeRush Xpress!
Please read on for further information about this great tool!
In December I watched a vid from MS PDC 2008 called Tips and Tricks For the Visual C# IDE by Dustin Campbell. It’s an awesome vid to get some great tips for Visual Studio but the biggest tip I got out of the presentation was about CodeRush Xpress! It’s a fantastic new tool to help you navigate code/files, select text, reduce code complexity, and aid in refactoring.
The first time I heard about this type of tool was from Jean-Paul Boodhoo who runs a Nothing but .NET Developer Boot Camp course. As part of your admission fee, you’re given a copy of JetBrains ReSharper which JP swears by! I was lucky to see JP give a presentation at Dev Teach 2008 Toronto and MAN does that guy fly across the keyboard! I thought I was good with shortcuts, but I look like I’m typing with hockey gloves compared to JP! Anyways, I never got ReSharper cause it was too expensive for my company to buy (yup $250/seat was too much for my company :<) and I wasn’t about to shell out $$$$ personally for something I could do manually (albeit a bit slower).
The most amazing thing about the tool is how simple it is to use. I downloaded it and within minutes found useful shortcuts I’m able to use immediately. In other words the “feature discoverability” is very high! It’s so straight forward, you only see options you’re able to use, when you’re able to use them! Check this example out to see what I mean.

What's cool about this tool is you're not bombarded with useless options/feature/functions which only confuse and confound you which only serves to frustrate you and eventually make you ditch the whole thing! In this case, you'll see you use the regular and already known Visual Studio Smart Tag (CTRL+.) feature to access CodeRush Xpress feature set. For this example, you're only able to flatten or reverse your conditional logic and you get tooltip help as well! The other cool thing is check out the vertical bars delimiting the code block scope! Very cool IMHO!
Here is a list of some other cool features IMHO!
- First things first, the easiest way to get access to the CodeRush Xpress toolset is with the Smart Tag, SHFT+ALT+F10 or even simpler CTRL+.
- Navigating files/code using more intelligent search capabilities (ex being able to search for parts of a name, as well as pascal name searches)(CTRL+SHFT+Q to navigate files and CTRL+ALT+F to navigate files)
- Speaking of pascal casing, if you use pascal or Camel casing, have you ever tried to select part of the token using CTRL+SHIFT+Arrows? Doesn't work very well eh? Well, you can use ALT+Arrows to smart select tokens by casings! That is VERY COOL!
- Have you ever wanted to select an entire block of code but have to mouse and SHIFT+.....blah blah blah just to select the entire if statement? Have you ever messed up? Happens a lot eh? Well using Smart Copy you can easily cut the entire block just using CTRL+C
- What if you wanted to select a piece of code? You can use the CTRL+ALT+- and CTRL+ALT++ as well to expand/collapse your selections
- Ever want find out where a token is used? Ya you can use VS Find Symbol feature but there's a faster way, try CTRL+ALT+u! But it doesn't stop there, want an ever easier way to find the next token? Check this out, put the cursor on a token, then the tab key, BINGO you're doing the same things as Find Symbols....queue the music while VS searches, then hit F8 to navigate, isn't the Tab key easier?! Want to go back to the beginning where you started, hit the ESC key and BINGO, you're back to the beginning piece of code, this is great for investigation or debugging purposes
- Refactoring properties is very cool too! You can quickly create a backing store, expand abbreviated properties and/or collapse to an auto implemented property
- Speaking of properties, if you have a big chunk of code just to set individual properties, you can quickly convert all those lines of code to initializers
- Quickly convert individual string concatenation to StringBuilder usage
- Easily collapse/expand ternary conditional statements
- Quickly add/remove block delimiters lets you quickly add delimiters around if blocks if someone forgot (like you? :>)
- Decomposing parameters lets you take a parameter object and convert it to elemental objects used in the method (if you're passing a Button into your method but only use the Name and Id, then you can decompose that parameter to convert the method to accept two strings instead, this could help make the method have wider appeal to other uses). The other cool thing here is the calling sites are also updated, not just the method signature is changed but the callers as well! SWEET!
- Extract method to type lets you quickly move pieces of code from one class to a more appropriate place in another class, again, calling sites are updated as well as the code moved.
- Move Type to File does everything you would do manually but with two mouse clicks (big savings for properly adding the correct namespace for you)
- And lastly, if you're still totally lost and don't know what refactoring options are available to you, check out the CTRL+~ and you'll quickly find out!
The only negative thing I can say about this tool is it does not respect Visual Studio 2008's CTRL for making the popups transparent (Refactor!... makes it disappear where Code!... doesn't work :<). But that is the only con to the entire tool!
So there you go! I've tried to sell you on CodRush Xpress for Visual Studio and convince you it will not only save you time but will add to your productivity! Good luck!
References:
|
|
|