How can I extract all classes into separate file?

ε祈祈猫儿з 提交于 2019-12-08 15:22:38

问题


I'm using the Resharper trial and VS2008. Is it possible to extract all classes from one file into a separate file? I'm able to do this using Resharper but it only seems to work for individual classes. This is to be used on a file that was auto-generated that is 65,000 lines long.


回答1:


If you're using ReSharper 5, on the solution explorer, press Ctrl+Shift+R to invoke the Refactor menu (or alternatively right-click and locate it) and select "Move Types into Matching Files"




回答2:


For those that are running a newer version of Visual Studio, there is yet another solution (I realize the question mentions VS 2008). Visual Studio 2017 offers functionality similar to what Eduardo Molteni described for CodeRush. You simply click on a class name, click on the light bulb icon to the left, and select "Move type to xxxx.cs".




回答3:


In addition to Scott's solution, there's a free refactoring tool in Visual Studio Marketplace called Move Type to File.

It can bulk move types to their own separate files, like so:

It also provides a quick shortcut to move a type highlighted by the cursor (default Ctrl + Shift + F1).

Saved me a LOT of manual work...



来源:https://stackoverflow.com/questions/3366027/how-can-i-extract-all-classes-into-separate-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!