locked
Is it possible to reverse engineer C# code into an UML Class Diagram? RRS feed

  • Question

  • I have an existing assembly with complex relationships between classes and interfaces that I would like to reverse engineer into an UML class diagram. Is this possible with the modeling tools in VS 2010? I am wondering how we could use these tools for legacy code without having to create diagrams from scratch?

    Also I found that the template bindings property in Class Diagram doesn't pick up any template types that I add to the designer surface in Beta2. So I cannot really create a class that is based on a template type. Is this something that will be resolved?
    Wednesday, January 6, 2010 7:04 PM

Answers

  • You can now download the Visualization and Modeling Feature Pack to create UML class diagrams from code.

     


    Esther Fan | VS Visualization and Modeling Tools, Content Lead | If a post answers your question, please click "Mark As Answer" on that post. Thanks!

    Monday, June 28, 2010 8:57 PM
  • Hi Anand,

    We couldn't get to reverse engineering (RE) for the UML class diagram in Dev10. It was just too big. We are working on the solution however. We'll release it as a high quality power tool in around Dev10 RTM. We did get RE into a ".NET sequence diagram" so you can RE straight from code. It's very cool.

    I'm a little surprised by your second question about templates. I wonder if the type of the template parameter is not set. Let me give an example.

    Suppose I want a IList of Employee classes. These would be the steps:

    1. Create an interface IList. Set its Template Parameters property to T:Class through the Template Paremeter dialog by adding a template parameter named T with Parameter Kind set to Class.
    2. Create a class Employee. Add whatever attributes/operations.
    3. Create an interface IEmployeeList. Set its Template Binding property to IList.
    4. In the Template Binding dropdown, only the templated interfaces will show. Once you commit that property setting, you'll get a new sub-property T:Class under the Template Binding property. This will let you bind T -> Employee.
    5. Click the T:Class property dropdown to get a list of classes and select Employee. Since T is a class, only classes will show in the dropdown. Had it been an Enumeration, only enums would have populated the list.

    As you can see in our templating funcationality, we try to be very specific about showing only the types/kinds that are allowed to be templated/bound. Also, though the binding relationship exists in the model, we didn't have time to get implemented (drawn) on the diagram. Therefore, the only way to understand the binding is to interpret/parse the name shown in the shape - IEmployeeList : IList<T->Employee>.

    I hope this clarifies. If not, please post back. Thanks.


    Phil

     


    Phil Lee | Program Manager | Visual Studio Architecture Tools
    Thursday, January 7, 2010 6:56 PM
  • Hi guys.

    Thanks for your continued patience.  The team is very excited to get these features shipped.  We are very close (nearer than 'near term').  Of course I can't give a date, but we're down to our very last bit of testing and bug fixing.  It'll be just a bit longer, but well worth the wait.  We are delivering a TON of new functionality!


    Phil Lee | Program Manager | Visual Studio Architecture Tools
    Thursday, May 13, 2010 5:42 PM

All replies

  • Hi Anand,

    We couldn't get to reverse engineering (RE) for the UML class diagram in Dev10. It was just too big. We are working on the solution however. We'll release it as a high quality power tool in around Dev10 RTM. We did get RE into a ".NET sequence diagram" so you can RE straight from code. It's very cool.

    I'm a little surprised by your second question about templates. I wonder if the type of the template parameter is not set. Let me give an example.

    Suppose I want a IList of Employee classes. These would be the steps:

    1. Create an interface IList. Set its Template Parameters property to T:Class through the Template Paremeter dialog by adding a template parameter named T with Parameter Kind set to Class.
    2. Create a class Employee. Add whatever attributes/operations.
    3. Create an interface IEmployeeList. Set its Template Binding property to IList.
    4. In the Template Binding dropdown, only the templated interfaces will show. Once you commit that property setting, you'll get a new sub-property T:Class under the Template Binding property. This will let you bind T -> Employee.
    5. Click the T:Class property dropdown to get a list of classes and select Employee. Since T is a class, only classes will show in the dropdown. Had it been an Enumeration, only enums would have populated the list.

    As you can see in our templating funcationality, we try to be very specific about showing only the types/kinds that are allowed to be templated/bound. Also, though the binding relationship exists in the model, we didn't have time to get implemented (drawn) on the diagram. Therefore, the only way to understand the binding is to interpret/parse the name shown in the shape - IEmployeeList : IList<T->Employee>.

    I hope this clarifies. If not, please post back. Thanks.


    Phil

     


    Phil Lee | Program Manager | Visual Studio Architecture Tools
    Thursday, January 7, 2010 6:56 PM
  • Is it possible to reverse engineer C# code into an UML Class Diagram in the RC version of VS2010 that was just released on Monday Feb 8, 2010. I want to move all my UML diagrams I currently have in enterprise architect to the new VS2010 modeling projects. I really would like to be able to do this without having to wait for the final release or having to manually recreating all my class. Any help or direction would be greatly appreciated.
    Friday, February 12, 2010 4:51 PM
  • We couldn't get to reverse engineering (RE) for the UML class diagram in Dev10.  It was just too big.  We are working on the solution however.  We'll release it as a high quality power tool in around Dev10 RTM.
    Hi Phil, Are you close to releasing this power tool? Thanks, Leroy
    Wednesday, April 28, 2010 3:53 PM
  • What's the word on the release date for reverse engineering code to UML class diagrams in Dev10? RTM for Dev10 was about a month ago and there is still no release date announcement from MS for the Visualization and Modeling Tools Feature Pack. I'm close to cutting my losses and jumping ship to something like Enterprise Architect (Sparks Systems) but will tough it out if a near-term release date is announced.
    Thursday, May 13, 2010 2:12 PM
  • Hi guys.

    Thanks for your continued patience.  The team is very excited to get these features shipped.  We are very close (nearer than 'near term').  Of course I can't give a date, but we're down to our very last bit of testing and bug fixing.  It'll be just a bit longer, but well worth the wait.  We are delivering a TON of new functionality!


    Phil Lee | Program Manager | Visual Studio Architecture Tools
    Thursday, May 13, 2010 5:42 PM
  • We are delivering a TON of new functionality!


    Phil Lee | Program Manager | Visual Studio Architecture Tools

    Does that "TON" contains a way to RE ad EDM (Entity Framework's Entity Data Model) and then have both model put in sync by VS? Consider this scenario: i have to model a simple "Party" pattern, and I have to manage persistence by means of Entity Framework.

    So I'm gonna use the EDM designer in order to put the model in place, but I also want to have an UML representation of the model. My questions are:

    - Will I be able to RE the EDM? (I think that this is going to be supported since VS generates code, so you'll be able to to a "classic" RE)

    - A quota of the code generated by VS starting from the EDM is "plumbing", being irrelevant from a model perspective. Will the power tool avoid to RE that code or, at least, generate a "clean" class diagram?

    - Will I be able to use the class diagram designer to alter the model and then commit the changes to the EDM? If yes, how are you going to manage the semantic differences between the models (ex: EDM does not have association classes, which are used quite a lot in UML class diagrams)

    - More generally, will both models (UML and EDM) be "in sync"?

    The "problem" is that it would be quite a PITA to have to model twice the same "conceptual" diagram, so IMVHO VS should offer an integrated UX

     

    best,

    .A


    .A GUISA - http://www.guisa.org UGIdotNET - http://www.ugidotnet.org Read my blog at: http://blogs.ugidotnet.org/pape
    Tuesday, May 18, 2010 5:14 PM
  • Hi Phil,

    I am looking for the same from T-SQL to UML.


    Please mark the post as answered to help others to choose the best.
    chandra sekhar pathivada | www.calsql.com (SQL Server Community Website)
    Thursday, May 20, 2010 8:45 PM
  • Cameron Skinner posted the functionality that will be available in this release:

    Sneak peek at the first “Feature Pack” for VS2010 Visualization and Modeling Tools


     



    Esther Fan | User Education | If a post answers your question, please click "Mark As Answer" for that post. Thanks!
    Thursday, May 20, 2010 8:48 PM
  • You can now download the Visualization and Modeling Feature Pack to create UML class diagrams from code.

     


    Esther Fan | VS Visualization and Modeling Tools, Content Lead | If a post answers your question, please click "Mark As Answer" on that post. Thanks!

    Monday, June 28, 2010 8:57 PM
  • It appears that the modeling pack can't properly generate a class that inherits from another class with a template parameter.  In the UML, I have the class:

     

    SubClass: SuperClass<T -> OtherClass>

     

    I would think the generated code would look like this:

     

    public class SubClass : SuperClass<OtherClass>

     

    But instead, it looks like this:

     

    public class SubClass : SuperClass<T>

     

    Which, of course, doesn't compile.

    Thursday, January 20, 2011 4:26 PM
  • After further testing, I found a workaround.

    I you create a third class, inheriting from the second class, which, in turn, inherits from the first, generic class then the first and third classes are generated.

    In UML terms, I have the three classes:

    1. SuperClass (which as a template parameter named T) <-- generates code
    2. SubClass: SuperClass<T -> OtherClass> (which inherits from #1) <-- does not generate code
    3. SecondSubClass (which inherits from #2) <-- generates code

    Thursday, January 20, 2011 5:01 PM
  • You can now download the Visualization and Modeling Feature Pack to create UML class diagrams from code.

     

     


     

    Esther Fan | VS Visualization and Modeling Tools, Content Lead | If a post answers your question, please click "Mark As Answer" on that post. Thanks!

    From looking at the links relating to this it seems this is only a solution if you have VS2010 Ultimate.  Is there anything that works for VS2010 Pro, which I have through an academic arrangement?  Otherwise, is there any way to upgrade from VS2010 Pro to Ultimate?
    Tuesday, October 18, 2011 11:29 PM
  • Though they're not UML class diagrams, you can generate code-based class diagrams for each project in VS 2010 Pro. In Solution Explorer, right-click the project, and then click View Class Diagram. Take a look at Designing and Viewing Classes and Types.


    Esther Fan | Visual Studio, Content Lead | If a post answers your question, please click "Mark As Answer" on that post and mark as Helpful. Thanks!
    Wednesday, October 19, 2011 1:08 AM
  • I appreciate your input, but a diagram driven by the data alone isn't a substitute for an integrated UML tool.  I'm also rather surprised--in today's world I would have thought that an integrated UML tool would be standard equipment; not something for which you need to go to "ultimate".     

    Wednesday, October 19, 2011 1:53 AM
  • ETA: even if I can't get a UML add-in for VS2010 Pro, just being able to generate sequence diagrams would be very helpful. 
    Wednesday, October 19, 2011 3:14 AM
  • I appreciate your feedback and have forwarded it on. May I also suggest that you submit your feedback at the Visual Studio User Voice site? That way, others can also vote for it: http://visualstudio.uservoice.com/forums/121579-visual-studio/category/30929-visual-studio-ultimate
    Esther Fan | Visual Studio, Content Lead | If a post answers your question, please click "Mark As Answer" on that post and mark as Helpful. Thanks!
    Wednesday, October 19, 2011 4:06 PM
  • I appreciate your feedback and have forwarded it on. May I also suggest that you submit your feedback at the Visual Studio User Voice site? That way, others can also vote for it: http://visualstudio.uservoice.com/forums/121579-visual-studio/category/30929-visual-studio-ultimate

    Esther Fan | Visual Studio, Content Lead | If a post answers your question, please click "Mark As Answer" on that post and mark as Helpful. Thanks!

    Here's a 2009 blog post I found about generating sequence diagrams from VS2010.  Is this also something that only works in VS2010 Ultimate, or was it a feature that didn't make it out of beta?

    (Link: http://weblogs.asp.net/gunnarpeipman/archive/2009/11/20/visual-studio-2010-generating-sequence-diagrams-on-the-fly.aspx)

    Thursday, October 20, 2011 8:16 PM
  • You'll need VS2010 Ultimate to generate sequence diagrams:

    How to: Explore Code with Sequence Diagrams


    Esther Fan | Visual Studio, Content Lead | If a post answers your question, please click "Mark As Answer" on that post and mark as Helpful. Thanks!
    Thursday, October 20, 2011 9:02 PM
  • You'll need VS2010 Ultimate to generate sequence diagrams:

    I just came back in here to say I've decided to light a candle rather than curse the darkness--I've decided to download a trial copy of Ultimate, which will give me 90 days all told.  This should be time enough for the purpose I have in mind.  Still, I hope a solution for VS Professional will be available one day.


    ETA: Uh-oh, there seems to be a problem.  I seem to have no choice other than to install Ultimate to the same path where Professional now resides.    Obviously I don't want to disable my VS2010 Professional installation when the Ultimate trial license expires in 90 days.  I also don't want to whack my present installation of the Professional version, because I will most likely have to go back to that. 

    How can I get around this?  I'm currently trying to do it with the Web install file.  If I download the Ultimate ISO file and use that instead, will I be able to choose the install path?

    (NB: I know what you're all thinking: why didn't I save a copy of the installation ISO?  Well, for whatever reason I have never been able to do this without eventually discovering that the disc copy is corrupt in some way or other, so I always have to re-download the giant ISO file. )

    Friday, October 21, 2011 5:49 PM
  • Hello.

    You'll have the same result with the ISO as with the Web installer. You cannot install VS Ultimate side by side with VS Pro.

    Do you have access to some subscription (for instance MSDN?).

     

    Best regards


    Jean-Marc
    Tuesday, October 25, 2011 10:47 AM