Saturday, November 21, 2015

Generate UML Sequence diagram from Visual Studio

Yes it is correct, you can generate Sequence diagrams for your code, from within the Visual Studio and that too automatically.No need to create it your self. Let's see how we can do this.

Let's create a new sample project. Let's add a static classes Class1 and static method TestMethod1 in this class. Now let's create a test method on Default.aspx and call it on the Page_Load event. This function, in turn, will call TestMethod1 of Class1So our code will look like the following:



Now, right click on the Page_Load event, and select the option "Generate Sequence Diagram". 



This will open up a window to define the settings to be used for generating this diagram. You can set what level of code it should consider for generating the diagram, whether to include the code within the entire solution or current project only etc.

Also, you can specify whether to save the diagram in current project or not. So we increase the call depth to 2 and keep rest of the settings as it is. 



Click "Ok" and it will generate the sequence diagram for the code we have.  


So the sequence diagram is ready. Just increase the "Maximum Call Depth" property and create the diagram to understand the code in easily. Happy Coding...!!!

No comments:

Post a Comment