The CodeRush References tool window is a wonderful thing.
Place your caret on a symbol and press Shift+F12 asking the question: “Where else is this used?”.
Next: Navigate the results with the Arrow Keys and Hit Enter to visit the selected reference.
Consider an example search for all the references to LightweightControlCollection in OpenLiveWriter:
The VS version of this is ok, but it’s very black and white and isn’t exactly very configurable. 50% of the screenshot below is taken up with the name of the file the code was found in.
Compare this with CodeRush version and I think you’ll agree, we improved things a lot.
A Brighter Outlook
The first thing you’ll notice about CodeRush’s presentation is the introduction of color. In the image below I have stripped away all the hierarchical feature of CodeRush. Even without all of that useful information, you’ll note that it is still easy to pick out XML Doc comments from class declarations, instantiations and constructors. These days we code in color because it helps us discern additional information about the code and the way the compiler sees it. Why should our search be limited to just black and white?
Despite the addition of color, there is still a lot of information to absorb in a list like this. Wouldn’t it be better if we could group the information in some sensible way?
Well CodeRush has you covered there as well. These 5 toolbar buttons allow you to specify which levels to group your references by. From left to right they are: Project, File, Namespace, Type and Member. They can all be toggled independently and provide additional collapsible parent nodes for your results.
You have complete control over the level of hierarchy you use. See above how I have chosen to use Project and Type nodes in my hierarchy. This immediately expands the amount of horizontal space allocated to the code, rather than the naming of the file in which it sits. Just take a moment to compare this image with the first one.
You can also elect to view a preview of the location of the selected item. Use the following icons to select between a preview on the right of your results, one beneath or no preview.
Filter by Usage
The icons next to each result reflect the type of usage. Either Reads, Writes or New Instances. If you so choose, you can filter your results by the type of their usage. The drop down box in the toolbar will allow you to filter by ‘Reads’, ‘Writes’, ‘New Instances’, or ‘All Usages’
See how the ‘New Instances’ choice reduces my previous list to only 2 entries.
Filter by Text
You may also filter the items in your results by text. Text entered in the Search box will cause CodeRush to remove all items that do not contain that text within their entry. See below how I have filtered by the word ‘index’ and removed all but those with this text present.
Refresh and New Search
There are 2 final icons that should be explained.
The first of these is Refresh. The entries in the References tool window do not update as you alter code. They reflect the state of the code at the moment you engaged the feature. Pressing the Refresh button will execute the original search update the results in the current Tab.
The second icon is New Search. When pressed, it will leave the existing results in place, and create a new Tab based on the original search criteria. This means that in the new Tab, the Usages drop down will be reset to ‘All Usages’ and the ‘Search’ box will be cleared.
Each new activation of the References tool window via the Shift+F12 key will cause an additional Tab to be created, allowing you to keep many sets of results active at once.
The References ToolWindow has never been better. It’s fast, clear and colorful in a meaningful way. With the ability to filter it’s results as well as arranging those results with the hierarchical elements you choose.
If you’ve not already got your copy of CodeRush, you can find a preview here on the Visual Studio Gallery