|
Project
|
ReSharper
|
|
Priority
|
Major |
|
Type
|
Feature |
|
Fix versions
|
Mirabile Futurum |
|
State
|
Open |
|
Assignee
|
Sergey Shkredov |
|
Subsystem
|
Refactorings |
|
Affected versions
|
No Affected versions |
|
Fixed in build
|
No Fixed in build
|
IMHO this is pretty strange feature. In most cases method will use fields, other methods. If you copy/move method to different class, should R#R copy/move used fields and other methods? Otherwise refactoring is breaking the code.
I can see when this feature is useful - for utility classes with only static members, which are stateless. But this is pretty rare case, copy/paste is enough.
I use Ctrl-W (Expand selection) to select entire member, then either copy or cut it. I sometimes use Ctrl-D to duplicate it in place.
I think this is a very important refactoring. It's a fundamental means of fixing a design mistake.
Break up a complex algorithm using Extract a method
Move some of those methods to a more relevant class (e.g. a Data Access class)
Identify a method that acts mostly on another class's data
Move the method to that class
Of course you can do this manually, but that's true of every refactoring...
Can you take care of every scenario? Maybe not, but there are definitely cases that you can automate.
E.g.
Moving a method to an instance used within that method changes all of the references of that instance to 'this'.
Give user the option of moving, passing as arguments or (less desirable) copying referenced fields to the same location if necessary
Give user the option to copy dependent methods (if possible) to the new location as well
Warn of breaking the code in a move method in cases that aren't automateable?