通过 ReSharper 将类型从一个项目移动到另一个项目?
我的业务层项目中有几个接口和类,我想将它们移至一个全新的项目中。我正在使用 ReSharper 4.5.2。有什么方法可以轻松且无痛地做到这一点吗?我知道移动类型功能,但它似乎只能在同一个项目中执行。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您只需将文件拖放到解决方案窗口中,然后使用 ReSharper 自动添加引用并修复任何命名空间问题。
我已经做到了——它不像移动类型操作那样需要 1 次操作,但它仍然非常快。
仅供参考 - ReSharper 5.0 Beta 2 现在直接支持此功能,只需右键单击解决方案窗口中的文件,然后选择 Refactor > 即可。移动。
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.
在当前版本的 ReSharper 中,“移动到文件夹”重构可以很好地处理此问题:
它不像拖放那么方便,但它仍然可以跨多个文件在一次操作中完成所有操作。
In the current version of ReSharper, the Move to Folder refactoring handles this fine:
It's not as convenient as drag-n-drop, but it still does everything in one operation across multiple files.
详细说明已接受的答案和评论这里有一个更简单的方法。
就像 @Dan Appleyard 所说,您可以使用 SHIFT+拖动来“移动”文件而不是“复制”,这也会触发(在 ReSharper 5+ 中)将新项目添加到需要的引用中。
完成此操作后,转到移动文件所在的文件夹,然后选择“右键单击 ->”重构->调整命名空间。这将更正文件所在的命名空间以匹配项目/文件夹结构,并将所有必需的
using
指令放入整个解决方案的所有文件中。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 requiredusing
directives in all the files in the entire solution.