Brondahl
Brondahl

Reputation: 8557

How to manually rearrange methods in a class with VS/Resharper?

I am specifically trying to rediscover a feature that I have previously seen. Does anyone recognise / know where to find, this feature?

In the past I have seen (and indeed, used) a feature of my IDE (VS + Resharper) which would pop-up a dialogue box with a list of all the methods currently in my class (and the regions, IIRC) and would allow me to drag-and-drop the methods with-in that popup window. Then when I click 'OK' (or whatever was on the button) it would automatically rearrange the methods in my class according to the changes I made.

This allows me to control and easily manage the ordering of my methods.

I'm 100% sure that this feature existed previously, and am looking to find out what it was called so that I can re-access it.

I'm ...75%? ... confident that it was a piece of R# functionality, but it might have been pure VS.

I would have said (maybe 20% confidence?) that the Keyboard-Shortcut at the time was Ctrl-Alt-F, but that now brings up "Resharper Code Cleanup", which appears to be a "re-order all my methods for me" dialogue? (maybe it's changed in the latest version of R#?)

Does anyone recognise this description?


**To Pre-empt, NO ... this is NOT a duplicate of either of these:**

Those question are about how to get Resharper to automatically sort your methods, based on rigid configured rules, which isn't the feature that I'm remembering.

I am specifically trying to rediscover a feature that I have previously seen.

Upvotes: 1

Views: 302

Answers (1)

user585968
user585968

Reputation:

In the past I have seen (and indeed, used) a feature of my IDE (VS + Resharper) which would pop-up a dialogue box with a list of all the methods currently in my class (and the regions, IIRC) and would allow me to drag-and-drop the methods with-in that popup window.

The closest thing I can think of is ReSharper's File Structure window. To open it select ReSharper.Windows.File Structure or press ctrl+alt+f (in my environment anyway).

enter image description here

The File Structure window appears. This is a live overview of the current source file (works with .cs as well as other files like .xaml). For .cs files you can drag and drop class members around in the file.

enter image description here

  • Want to apply your own manual method ordering? You can do that
  • Want to put fields at the top. You can do that
  • Want to create/edit/delete regions for your methods. You can do that too

To move a member around just drag and drop it.

enter image description here

OP:

Then when I click 'OK' (or whatever was on the button) it would automatically rearrange the methods in my class according to the changes I made.

File Structure doesn't do any anything automatically. Perhaps you are thinking of Code Cleanup? That is still present in R#.

Upvotes: 2

Related Questions