Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move file/class to another project

Is it possible to move a class to another project with the help of Visual Studio or Resharper (with or without a plugin)?

Would make TDD a tad easier.

Update

I use Resharper to create the class directly from the test method. The class is added in the same file as the test class. I can then ALT+Enter on the class to move it to a separate file. After that, I manually drag the file to the other project.

But I would like to have a way to move it to another project directly without having to drag it. Something like ALT+ENTER on the non-existent class and choose "Create in Project Y"

like image 293
jgauffin Avatar asked Apr 22 '13 11:04

jgauffin


2 Answers

"Shift + Drag" in VS Solution Explorer allows you to move file(s). You can then use Resharper to fix the namespaces

like image 158
Timje Avatar answered Nov 03 '22 09:11

Timje


With resharper: Right Click (on file in Solution Explorer) -> Refactor -> Move.

Edit by jgauffin:

  1. Put the cursor over your non-existant class in your test method and press ALT-ENTER
  2. Choose to create the class in the context menu
  3. Press END to move to the class name
  4. Press CTRL+SHIFT+R to bring up the Resharper Refactor menu
  5. Press key DOWN for "Move to folder" and then press ENTER
  6. Press TAB in the new dialog and then ENTER to show the Target tree view (below the combo box)
  7. Navigate with the arrow keys
  8. Press ENTER when done
like image 5
Nikita B Avatar answered Nov 03 '22 07:11

Nikita B