Move type from one project to another via ReSharper?
Asked Answered
J

3

20

I have several interfaces and classes that I have in my business layer project and I want to move them into a brand new project. I am using ReSharper 4.5.2. Is there any way I can do that easily and with no pain? I know about the move type functionality, but it seems like it will only do it within the same project.

Jonahjonas answered 25/2, 2010 at 22:37 Comment(0)
K
31

You can just drag and drop the files in the solution window, then use ReSharper to automatically add the references and fix any namespace issues.

I've done it - it's not as 1-operation as the move type operation, but it's still very fast.


FYI - ReSharper 5.0 Beta 2 now supports this, directly, by right clicking on a file in the solution window, and choosing Refactor > Move.

Kerplunk answered 25/2, 2010 at 22:38 Comment(3)
When i do that, it simply copies the file from the one project to another. Is that what happens for you?Jonahjonas
@Dan Appleyard: Hold down "shift" as you drag, and it will move the file instead of copying it.Kerplunk
Alternative workflow (at least with Resharper 7.1.1, don't know about earlier versions): Select the file to move in Visual Studio Solution Explorer then Ctrl+R, Ctrl+O. The Resharper Move To Folder dialog will open, allowing you to browse to the folder to move the file to. The folder can be in another project. Has the option of updating the namespace appropriately, and all references and using statements in other projects and files that point to the file being moved.Saucer
P
5

In the current version of ReSharper, the Move to Folder refactoring handles this fine:

  1. Select the files in Solution Explorer or the type in the code editor.
  2. Open the context menu (right-click or press Context Menu on your keyboard).
  3. Select Refactor.
  4. Select Move.

It's not as convenient as drag-n-drop, but it still does everything in one operation across multiple files.

Perr answered 30/7, 2014 at 23:48 Comment(0)
J
2

To Elaborate on the accepted answer & comments here there's a simpler way.

Like @Dan Appleyard stated, you can use SHIFT+Drag to "Move" the file instead of "Copy", this will also trigger (in ReSharper 5+) the new project to be added to the references where needed.

Once you've done this go to the folder the moved file is in and choose Right Click -> Refactor -> Adjust Namespaces. This will correct the namespace the files live in to match the project/folder structure and will go put all the required using directives in all the files in the entire solution.

Jillane answered 3/5, 2013 at 0:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.