Welcome to day 9 of my 31 Days of ReSharper.
Yesterday I talked about one Visual Studio feature (Find All References) that ReSharper replaced, enhanced, and changed the keystroke for. Today I’ll talk about another: Parameter Info, formerly Ctrl+Shift+Space.
ReSharper’s parameter info, accessible via Ctrl+P, shows all the overloads at once, instead of just one like Visual Studio’s:
Visual Studio’s parameter info
If the method you’re calling doesn’t have any overloads, ReSharper’s parameter info is pretty similar to Visual Studio’s. But if you ever call overloaded methods (i.e., if you ever use anything in a Microsoft-provided assembly), the new parameter info has several decided advantages:
See where you’re going. Whenever I’m writing custom painting code in .NET, I have to face the dreaded Death by Overload. Seriously, what is up with System.Drawing? Some of the methods have 30 different overloads. When you know you want an overload that takes ImageAttributes (and of course they’re all way at the bottom of the list), it’s nice to be able to see lots of overloads at once.
You can use the cursor keys! When Visual Studio’s Parameter Info tooltip is visible, you can’t use the up and down cursor keys — VS hijacks them to mean “show the parameter info for the next/previous overload”. I’ve had to develop the habit of hitting “End” followed by “Right arrow” when I want to move to the next line (or “Esc” followed by “Down arrow”, but those keys are a lot farther apart…) But with ReSharper, you use Ctrl+P and Ctrl+Shift+P to cycle through the overloads, not up and down. So the cursor keys are available for actually moving through your code. Sweet!
Skip the ones that don’t apply. When you use Ctrl+P and Ctrl+Shift+P to cycle through the overloads, it will only step to the overloads that match the parameters you’ve already entered. For example, in the above code, I’m calling Graphics.DrawImage, and passing an Image and an int. If I press Ctrl+P again, it will skip the next overload in the list, because it takes a Rectangle as its second parameter — obviously not one I want, because I’m not passing a Rectangle. Instead, it will go two down, to the next overload that takes floats.
According to their Web site, ReSharper’s parameter info is supposed to show inapplicable overloads in gray. Unfortunately, this feature is broken in ReSharper 2.5.1 (I told support about it, and they said it’s supposed to work; they’re looking into it.)