Reverse Engineering C# projects  
Author Message
Dave Yasko





PostPosted: Visual Studio Team System - Architecture & Design, Reverse Engineering C# projects Top

Hello,

I'm trying to reverse engineer a UML model from my very large solution and it's not working. I'm hoping someone reading this can help.

I've got a solution with 170+ projects. Three are C++ projects, the others C#. I've got all but 9 C# projects unloaded. I select the solution node in the solution explorer, then select Project->Visio UML->Reverse Engineer. DevStudio says it completed, Visio starts, but all I get is an empty UML model. Below is the output window results:

Performing pass number: 1.

Performing pass number: 2.

Number of warnings: 0.

Exporting UML model to Visio...

Reverse engineering succeeded.

I'm running DevStudio 2005, and Visio for Enterprise Architects. Some of my projects were created with Whidbey Beta1, others with Beta2. All of my assemblies are strong named. One thing that might be of interest is that all of the projects have file references to the output assemblies of the other projects (for reasons I won't go into now).

I'm able to reverse engineer UML models for individual projects, just not the solution as a whole. Has anyone seen this before

Thanx in advance,

Dave



Visual Studio Team System28  
 
 
Ramesh Rajagopal





PostPosted: Visual Studio Team System - Architecture & Design, Reverse Engineering C# projects Top

Hi Dave,

Could you try performing the same in a solution that has a couple of projects Does it work okay in that case We are wondering if the problem you are seeing is due to the high number of unloaded projects.

Cheers,

Ramesh Rajagopal.



 
 
Dave Yasko





PostPosted: Visual Studio Team System - Architecture & Design, Reverse Engineering C# projects Top

Ramesh,

Thanx for the reply. Did you recall a previous message I received an email with a different response (which I'd have to disagree with). The Visio help specifically states that it supports reverse engineering at the solution level, and it works with new solutions.

To answer this message, I did try a new trival test of a new solution with 3 new projects, and reverse engineering works just fine with that solution. I tried reloading all the projects in this solution, but it acted exactly the same, same output window contents, same empty Visio diagram. There was one difference however, it took longer to do that same amount of nothing.

Some other things that might be useful to know: While the vast majority of projects are C# class libraries, some of the unloaded projects are unmanaged C++ projects, there are several C# application projects, and most of the projects were created with Whidbey Beta2.

Dave


 
 
Ian Bavey





PostPosted: Visual Studio Team System - Architecture & Design, Reverse Engineering C# projects Top

Hi Dave,

You are correct that Visio does support reverse engineering the entire solution as well as individual projects. Could you try creating a new solution and then adding a small number of the projects from your existing solution to see if you are able to reverse engineer that As Ramesh says, it's possible that the size of the solution and the number of unloaded projects is causing a problem. The mix of C# and C++ projects shouldn't be an issue as that is a supported scenario.

Thanks,

Ian Bavey
Software Development Engineer
Visual Studio Team Edition for Software Architects


 
 
Dave Yasko





PostPosted: Visual Studio Team System - Architecture & Design, Reverse Engineering C# projects Top

Ian,

Thanks for the reply. I did try reloading all 170+ projects to no avail. I can try with a new solution, adding a few projects at a time, but you can imagine how painful that might be. Has anyone there ever tested this functionality with anywhere near this many projects or am I the first

Also, I've noticed that the Visio models produced only depict class inheritence and interface implementation. Is it possible to also indicate type usage and composition without having to manually add those relationships

Thanx,

Dave


 
 
Ian Bavey





PostPosted: Visual Studio Team System - Architecture & Design, Reverse Engineering C# projects Top

Hi Dave,

You're right, rebuilding the solution with all 170+ projects would be painful. Right now my goal is to see if adding a few projects to a new solution allows you to successfully reverse engineer those projects. It's quite possible that there are just a handful of projects that are causing the problem and if we can identify those projects then we can at least get the majority of your solution into a model. Most of our testing is done with smaller solutions than the one you are using.

You are correct that Visio only reverse engineers inheritance and interface implementation relationships. You'd have to manually add other relationship types to your model after reverse engineering it.

Please let me know if the mini-solution works.

Regards,

Ian Bavey
Software Development Engineer
Visual Studio Team Edition for Software Architects


 
 
Dave Yasko





PostPosted: Visual Studio Team System - Architecture & Design, Reverse Engineering C# projects Top

Something else just occurred to me. I've got my projects organized into many, MANY folders and subfolders in my solution. For examle:

Solution - MySolution

- _SolutionFiles (folder)

MyKey.snk (file)

- SomeRootFolder

- SomeSubFolder1

- MyProject1Folder

MyProject1 (project)

- MyProject2Folder

MyProject2

etc...

Does that make sense With that many projects, it is really necessary to keep the solution really organized.

Dave


 
 
Ian Bavey





PostPosted: Visual Studio Team System - Architecture & Design, Reverse Engineering C# projects Top

That's almost certainly your problem as, unfortunately, we don't walk into folders to look for projects (at least not in the version of the code I'm looking at). At this point your best bet is to create a second solution containing all of your projects in a flat hierarchy and reverse engineer that solution. You could use the DTE automation APIs to write a macro that would simplify this work.

Ian Bavey

Software Development Engineer

Visual Studio Team Edition for Software Architects


 
 
Dave Yasko





PostPosted: Visual Studio Team System - Architecture & Design, Reverse Engineering C# projects Top

I started seeing that in my test solution when I received the alert for your reply. Then I tested it by putting my projects in folders and seeing what didn't make it into the visio UML model. Should I post a bug on the Ladybug site, or is this thread enough to get the ball rolling

Thanks for your help. Btw, what DTE automation APIs Is that a way to more easily modify a solution file than that the text manipulation I've been doing I've got a program I wrote that parses the sln file, finds all of the projects therein, reads all of the specified project files to determine which projects have file references to each other, then it mods the sln to add project dependencies to each project so that I've got the correct build order. Is there an API that makes it easier for me That would be too cool.

Thanx,

Dave


 
 
Ian Bavey





PostPosted: Visual Studio Team System - Architecture & Design, Reverse Engineering C# projects Top

Ladybug is your best bet as bugs logged there get more visibility.

If you bring up the Tools->Macros->Macros IDE you can write your own macros that automate tasks in VS. DTE is the root object and you can access the solution and projects from it. For example, if you fill in the parameters in the method below it will add an existing project to a solution. You could write a simple macro that walks your existing solution and writes the filenames of each project to file, then write another macro that reads the file and calls AddFromFile to add your projects to a new solution. There's a lot of online help that explains the DTE object model much better than I can - you can get a starter to it by typing the macro below, selecting AddFromTemplate, and pressing F1.

Sub AddExistingProject()

DTE.Solution.AddFromFile(...)

End Sub

Ian Bavey

Software Development Engineer

Visual Studio Team Edition for Software Architects


 
 
Dave Yasko





PostPosted: Visual Studio Team System - Architecture & Design, Reverse Engineering C# projects Top

Thanx, I'll give that a try. I was able to reverse engineer a large portion of the solutiuon, but ran into a few issues. Most of them are with Visio, the confusion it experiences when there are multiple constructors for a particular type, but I think I can live with that.

Thanx again,

Dave


 
 
Esther Fan MSFT





PostPosted: Visual Studio Team System - Architecture & Design, Reverse Engineering C# projects Top

Re-marking answer to this post.

 
 
Ray Ray





PostPosted: Visual Studio Team System - Architecture & Design, Reverse Engineering C# projects Top

I think putting 170+ projects into one solution you maybe the first, but what kind of solution which needs 170+ projects to accomplish I just wonder. If I were you, I will group related projects (component level) into multiple solutions which is much easier to put everything in one solution and do you have problem navigating from one project to another one I won't expect this light weight tool would perform what you looking for.

 
 
Dave Yasko





PostPosted: Visual Studio Team System - Architecture & Design, Reverse Engineering C# projects Top

Actually, the 170+ projects reflected 4 or 5 executables, several server side service assemblies, 2 VSTO projects (Word and Excel), and all of the shared components. It is a HUGE project (not VS project, just work project). There are several smaller solutions, each project can be loaded by at least 3 solution files at different levels of the filesystem heirarchy. This "master solution" is simply an organization tool so that all of the source can browsed, searched, built, etc, from one DevStudio instance.

The surprising thing is that this solution found a circular reference that snuck into our project some time ago. Also, it works great, except that reverse engineering multiple projects doesn't work if those projects are in solution folders. Go figure. A copy of that solution where all of the projects are flat (not organized into folders) worked fine for the reverse engineering.

Dave