开发者

Move type from one project to another via ReSharper?

开发者 https://www.devze.com 2022-12-21 02:35 出处:网络
I have several interfaces and classes that I have in my business layer project and I want to move them into a bran开发者_运维问答d new project.I am using ReSharper 4.5.2.Is there any way I can do that

I have several interfaces and classes that I have in my business layer project and I want to move them into a bran开发者_运维问答d 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.


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消