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
  • Created by   Colin
    5 years ago (05 Aug 2006 02:14)
  • Updated by   Jura Gorohovsky
    6 months ago (10 Nov 2011 14:18)
  • Jira: RSRP-5777
    (history, comments)
 
RSRP-5777 Copy/Move method.
6
Issue is visible to: All Users
  The issue is visible to the selected user group only
I'm looking for a feature similar to copy/move type except with this I'm only wanting to copy/move a method. Upon right-clicking a method name and selecting copy/move I would expect a dialog to come up that has two multually exclusive options (denoted by radio buttons) The first would be "To existing class: " followed by a DDLB with all existing classes (perhaps separated by namespace for usability). The second option would be "New class: " followed by a textbox where you can enter the new class name.
Comments (3)
 
History
 
Linked Issues (?)
 
TeamCity Changes (0)
 
Ilya Ryzhenkov
  Ilya Ryzhenkov
07 Aug 2006 17:53
5 years ago
Re: #5777- Copy/Move method.
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.
Geoff Lane
  Geoff Lane
18 Dec 2007 21:13
4 years ago
"Moving methods is the bread and butter of refactoring" – Martin Fowler (Refactoring, pg 142).
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?
Maxim Filimonov
  Maxim Filimonov
04 Jul 2011 05:38
10 months ago
Why is this "strange feature" is implemented in IDEA http://www.jetbrains.com/idea/features/refactoring.html#Move_Instance_Method and can't be implemented in ReSharper? This feature was requested multiple times but always ignored by the ReSharper team but not the IDEA team which is a bit unfair to us .NET developers.