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.
Probably the most common approach to spreading a class's code over multiple files is to use subclassing, with the base class in one module, and the (or each) subclass, in its own separate module.
It is good practice to do so. You can easily find the class if you name the file after the class.
Press Ctrl+Shift+R and then choose Extract Class. Right-click and choose Refactor | Extract Class from the context menu. Choose ReSharper | Refactor | Extract | Extract Class… from the main menu.
Unlike Java, C# allows you to write multiple classes in a single source file.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With