ReSharper, day 8: Find Usages

Welcome to day 8 of my 31 Days of ReSharper.

As I mentioned in the survival guide, ReSharper replaces Visual Studio’s Find References (Shift+F12) with its own Find Usages (randomly changed to Alt+F7). Here’s more info on how their version differs from the one in Visual Studio.

Filtering for “get” or “set” usages

Ever had a property that’s read all over the place, but only set a few places, and you wanted to Find References to just the property setter? Here ya go.

ReSharper's Find Results window, showing the filter menu and its options to show only read or write usages

This also applies to fields: you can find only places where a field is read, or only places where it’s written. (Man, if Reflector only had this feature!)

As you can see from the screenshot, the Filter menu in the Find Results window has options for “Show Read Usages”, “Show Write Usages”, “Show Invocation Usages”, “Show Other Usages” (I’m not sure what that means), and “Show Usages in Documentation” (I assume this means XML doc comments). I thought “Show Other Usages” would mean making a delegate that references a method, but apparently they use “Show Read Usages” for that.

They’ve said that in a future version, you’ll be able to right-click on the “get” or “set” keyword inside a property declaration, and select “Find Usages”, and get just the read or write usages, as appropriate. I’m looking forward to that one.

Stepping through the results

After you do a Find Usages, you can use Ctrl+Alt+Up and Ctrl+Alt+Down to step through the results. It’ll put the cursor on the next result, opening another file if necessary. It doesn’t wrap when you get to the end, which is nice in a way, because it tells you you’re done.

The Find Results tree

On the downside, I don’t really like the way they present the search results in the Find Results window.

In Visual Studio, everything was just shown in a list:

Visual Studio's Find Symbol Results window

Every entry shows the filename and line number (and column number, as if you cared), so you at least know which class each reference is in. In ReSharper, on the other hand, everything’s in a tree:

ReSharper's Find Results window, showing search results that are initially collapsed

The tree starts out collapsed every time, so you’re always at least one click (Expand All) away from even seeing your results. And if you change the “Group by” setting to “None”, in an attempt to get rid of those layers of tree and see your results right away, then you don’t get anything telling you which file a result came from: each line will show just the text of the matching line of code, but no filename or line number information.

(I sent in an enhancement request, asking for the ability to show the results expanded by default. They said that there were a lot of other people asking for the exact same thing, so we may see that happen at some point.)

On the other hand, once you do get them expanded, they can tell you not just which class the result was in, but also which method, something VS’s list doesn’t do.

Leave a Reply

Your email address will not be published. Required fields are marked *