views:

162

answers:

4

I want to be able to refactor 500 projects at the same time.

I have about 20 solutions and I don't have a master solution with everything because I haven't figured out a way to auto generate it.

Any suggestions?

Thanks

Edit

I've tried slnTools from codeplex to generate a solution and visual studio pretty much took down the entire operating system. Not sure if it was the solution not being generated properly or if it was just a limitation of Windows / Visual Studio.

A: 

I think there is nothing done to satisfy your need.

You could try slnTools to see how manipulate sln files, and merge them into one .sln file.

But I'm not sure if Visual Studio can handle well 500 opened projects.

Victor Rodrigues
500 opened projects (shudder) ;-p Could be funny, though...
Marc Gravell
+2  A: 

What exactly is it you want to refactor? ReSharper is probably the best known tool for large scale refactorings... but whether it is appropriate depends on what you want to do.

You could always download the trial and give it a whirl...

Marc Gravell
ReSharper is fantastic, but it's a bit of a memory hog. I wouldn't try it with 500 projects right off the bat -- I'd start with maybe 25 and work up, and see how well it copes.
Joe White
Yes... but 500 projects / 20 solutions... gives 25 projects at a time, so I think we're in agreement.
Marc Gravell
And saying that it (or Visual Studio, for that matter) is a "bit" of a memory hog is like saying that I use stackoverflow a "bit" too much ;-p
Marc Gravell
+1  A: 

If they all share the same business / data domain libraries, you can refactor that and then update the references in the projects.

More likely you want to create that business / data domain from these distributed projects. I don't know the details, but I'm willing to bet that smashing 20 solutions together won't help you in refactoring out common code.

  1. I would start small, and create a new solution that is your common application bits.
  2. Pull the obvious pieces of common code into that solution, and reference it's compiled dlls in your other projects.
  3. Review your projects and repeat until you have something resembling the structure you are looking for.
Matthew Vines
I concur. Tools can only help you so far in refactoring. I don't know of anything that will find methods and behaviour in common with multiple projects and outsource it into separate libraries. Even if I did, I wouldn't trust it to organise that information - to make human-readable code, you should really be, well, human.
Samir Talwar
+2  A: 

To create the huge solution, you should be able to start with a macro vaguely like this:

    Dim d As New System.IO.DirectoryInfo(System.IO.Directory.GetCurrentDirectory())
    For Each f As System.IO.FileInfo In d.GetFiles("*.*proj")
        DTE.Solution.AddFromFile(f.FullName)
    Next
    DTE.Solution.Close(True)


Before you start the mega-refactoring, I'd suggest you use something like NDepend to analyze the dependency structure of the code, and compare it to your goals for refactoring. You'll only need projects in memory that will be affected by a particular refactoring. If you can limit the set that are needed, you'll greatly benefit.

If you can't get them all into memory, you should still be able to partition the work - you'll just have to repeat it. Consider the case where you've got a single class library that is used by ten other projects, and you want to refactor the public interface.

  1. Save a copy of the class library
  2. Load Project 1 and the class library, and do that refactoring. Close the solution.
  3. Restore the class library from the saved copy.
  4. Load Project 2 and the class library, and do that refactoring again. Close the solution.

etc. Finally, keep the last changed copy of the class library. If you really repeated the refactoring, all ten projects should be happy.

I'd also take the opportunity to refactor towards flexibility, so that you won't need to do this again. Accessing the class library through interfaces or facade classes can isolate you from changes in public interface.

John Saunders