Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move method to new file and keep it in the same class(make it partial)

I have a lot of classes with several methods. And i need to separate each method of the class in its own file, but kept they in the same class( make it partial).

Exploring the R# 6.1 options i haven't found linear possibility. May be there are hidden options?

Thanks

Added:

This refactoring is not usual because this code is UI tests, that grouped in class by the part of functionality. We need to separate them to be able to work on them separately from source control.

like image 622
Deitro Avatar asked Mar 05 '12 15:03

Deitro


1 Answers

I'm using ReSharper 5.1 and do not know such refatoring in one step.

The fastest way I know is:

  1. Create partial classes
    Write a second declaration of partial class with empty body and copy/paste or double (Ctl+D) it so often as the count of different files should be.
  2. Create files
    Go to every class declaration, press Ctrl+Shift+R and select Move To Another File..., enter a new file name and press OK.
  3. Move methods
    Do for every method to move: Go to method, press Alt+Enter, select Move declaration(s) to another type part and select file.
like image 142
brgerner Avatar answered Oct 20 '22 00:10

brgerner