I've started to refactor/clean up big project. Some of files contains few small classes or few enums (yeah, it is very messy;/ ).
Is there some method or tool to automatically divide files with few enums/classes and create separate files for each of them?
As Fredrik Mörk said - Resharper is very good tool and has possibility to do what I need. But of course as almost all good tools it costs (for one it is cheap, for another not:) ).
Maybe there is some free tool for such simple refactoring? (my boss will not pay for Resharper - he told me that I need 'hammer' not a whole workshop:) )
Of course you can separate out 2 classes and still they will work fine. Just make sure you import one class in another using import statement. All you need to do is move AnotherClass class into a separate source file named with name same as class name ie "AnotherClass.
As Paolo said,there is no benefit keeping many classes in a single file. Putting them in separate files will help you and any other programmer to find the cs file for a class quickly. By all that is right in the world, yes, it is correct!
Resharper has a refactoring that moves a type to a separate file. Might be that it can be applied on a higher level (as project); don't have it installed on this machine to verify though.
Edit: noticed in the online help that there is a refactoring called Move Types Into Matching Files that does exactly what you are asking for.
CodeRush xpress (free) also supports Moving a type into a matching file
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