free hit counter April 2007 - Posts - Nauman Leghari's Blog

April 2007 - Posts

More here

Finally I managed to put it on CodePlex.


Update: SequenceViz for Reflector


SequenceViz can now show dependencies between different modules.  It is probably not as good as some other proprietary softwares but it is fine for a start and I'm hoping to add more to this in the next release.

As always, here is a screenshot for the assembly dependency view.

"Dependency Explorer uses the Netron Graph library to display graphs so a huge thanks to Francois who gives us Netron and Unfold."

Here is another screen shot of the type dependency graph

You can see that the interfaces are shown in a different way to make it more obvious. The anchor direction is towards the interface to illustrate that the type implements the interface.  In this version, only the base type and the interfaces are classified as dependencies. I looking to include the private/public fields into that list as well; which will then show the true picture of the selected type.

In some cases, you will see clutter like the following due to the large number of tree nodes.

Here you can either Zoom (Ctrl + Mouse Wheel) to see this view in more detail or you can filter out specific type of items by using the options on the top of the screen. Here is the same diagram with types filtered out.

Currently, it is also not possible to filter out individual types from the user interface. In case you want to remove any individual type(s) then check the IgnoredTypeList property in the LiveSequence.exe.config file. The default setting looks like this.

<add key="IgnoredTypeList" value="Form|Type|Control|ControlCollection|String|Assert"/>

Hopefully, I'll also try to include filtering directly from the user interface. As always, try this out and see if you can get any benefit from this. I'll appreciate your comments or suggestions.

Download SequenceViz 0.4 (Source + Binaries)

** I have no problem if you are willing to add this to Reflector. I may not help you in writing any code in that case but I'll be able to help in any other issue.

With the help of Mike and Steve, finally there are few visitors coming to the site looking for SequenceViz. For those new visitors and the existing loyal readers (if there are any :)), here is another version of SequenceViz.


If you like SequenceViz or not, Spread it by Kicking It @ DotnetKicks or Digging It @ And subscribe to RSS to get any new releases.


A quick screenshot first.



 New Additions:


1) Namespace Supports:

Now you can see in the assembly tree that the classes are grouped under namespaces.


2) Assembly Pie Chart:


In this version, I put a Tab control to easily add multiple views of the assembly data.



Assembly Stats is a new view where you can see the size of assemblies and namespaces. It works when you either select Assembly or Namespace in the left hand pane and switch to Assembly Stats tab.


If you have selected an assembly then the pie charts shows the different namespaces within the assembly. The size of each pie is proportional to the size of classes in each namespace. For eg. Here is a nice view of log4net assembly. You can see that the classes are nicely distributed among namespaces.



The view changes when you select a namespace as shown below. Now it shows the different classes in the selected namespace . Similarly, the size of the pie in this case is proportional to the size of methods in each class.



I was initially thinking about adding the chart to show the number of IL count for each method. In the end, I decided not to go along that path because IL doesn't reflect the true number of lines in a higher level language and can give an incorrect picture.


Finally, a big thanks to ZedGraph for building a wonderful open source chart package which comes with excellent document even though it is really really simple to use.


The Future:

I'm trying to setup a CodePlex project so that SequenceViz can get its own home, but currently there are few areas of that website not working so I'll to wait until that get fixed.  In the meantime, if you would like to see anything in the next release then please leave your comments. The main theme of SequenceViz is to use visualization to help people understanding an existing project.


For comments on putting this as Reflector Plugin:

I would like to control the shell and now as I am getting comfortable with using Cecil therefore I am sorry that I won't be able to integrate this in Reflector any time soon. In addition there are some features that I want to see in SequenceViz which would not be possible without controlling the shell application.



SequenceViz 0.3 (Source + Binaries)


For SequenceViz, the next thing on the list was to export the SVG output to an image. I would like it to be included within the application but unfortunately I am unable to find a working implementation which I can use. (tried SVG# but didn't wok).


There are few ways where you can take the generated SVG and convert it into a raster image manually. These options are described below:


Please note that the SVG image of the diagram is generated to a file named Seq.svg before rendering in the browser control. So that is the file you should be converting.


1) Apache Batik:

Apache Batik is a wonder Java toolkit to manipulate SVG images and it does a lot more than that. See the website ( for more information. For our purpose, it includes a tool called SVG Rasterizer ( which can convert SVG file to a raster format.  There is sufficient information on the website to use that tool therefore I would recommened you to look at the above website.


2) Inkspace: (

Inkspace is an open source vector graphics editor similar to Illustrator, Freehand and Corel Draw. It can also be also to convert SVG to other formats.


Letme know if you have more information on any other way to convert SVG into other formats.


What is SequenceViz?

SequenceViz is a tool to generate sequence diagrams by reverse engineering .NET Assemblies. Read this post for setup and installation.

The latest release has the following enhacements:

1) Assembly Stats:

Now, you can see few stats about the loaded Assembly.


2) Selected Method Description



3) List constructors along with other methods (shown above)


4) Nice Icons :)


Download SequenceViz 0.2 Sources (Binaries Included)

UPDATE: SequenceViz 0.2 is released. Download from the same link below to get the updated version. Read this post for what is new.

Like MethodViz, this is another attempt to understand the source code visualization. SequenceViz automatically generates the sequence diagram from the assembly. Here is a screenshot of the running application.



It uses Cecil to parse the assembly and generate the data to build the sequence diagrams. The diagrams itself are build using a component from UmlGraph (sequence.pic) and running the generated file through pic2plot from the Gnu plot utilities. Please note that this is not a replacement for the documentation and the main purpose is to better understand the exiting project.


Process Flow:


Assembly -> Cecil -> Data -> Pic file -> Pic2Plot.exe -> Sequence Diagram


Don't worry about all the different components as most of it is bundled in the application.



a) Gnu windows port for Plot utilities.

b) SVG Plugin for Internet Explorer.


How to use SequenceViz:

After installing the Gnu Plot utilities, you can download SequenceViz from the following link.


Download Source (Binaries included)


If you have downloaded the binaries or just trying to get a quick look, you can start by configuring only a single property in the LiveSequence.exe.config file.  In case you downloaded the source, this file is under the bin\Debug folder.



    <add key="Pic2PlotPath" value="C:\Program Files\GnuWin32\bin\pic2plot.exe"/>

    <add key="OutputType" value="svg"/> <!--currently only svg format is supported-->

    <add key="IgnoredMethodList" value="get_|set_|add_|remove_"/>

    <add key="IgnoredTypeList" value="System|Assert"/>

    <add key="IgnoredAssemblyList" value="mscorlib|System"/>

    <add key="IncludeAssemblyReferences" value="false"/>



Make sure you have the correct GnuPlot installation directory above. Leave the other properties for now. You can start the application by running the LiveSequence.exe file.


Now, to try an sample assembly, just click on the File menu -> Select Load Assembly. Then select CecilCase.dll which is in the same directory.



Expand CecilCase to see all the classes and subsequently expand any class to check the methods. I know it is not looking pretty without any tree icons :).



Now, you can select any method to generate the sequence diagram which will be automatically displayed in the web browser control on the right hand panel.



There are a couple of annoyances that you may find. First, you'll see a black window flashing just after you click on the method name. That is basically the console which is displayed on the command link call to pic2plot.exe application to generate the svg file. The SVG file is then rendered in the browser control.


The other issue is shown below:



By default, on clicking the method, the diagram is not centred automatically therefore you may need to drag (Alt+Mouse Move) it around to view properly. Or maximize the window.

Thats it; not bad for a useful fee tool :P .



The following tools are used in making SequenceViz.


Cecil for reading IL by Jb Evain

Excellent PHTree control from CodeProject by Peter Chen

GNU Plot utilities - Win32 Port (There is a treasure in there waiting to be utilized)

PIC File macros for Sequence Diagrams from UMLGraph by Diomidis D. Spinellis (blog)

Log4Net for logging


Thank you guys for providing these.


As always, I really appreciate if you try this and see if I can add any other features.


Update on MethodViz: MethodViz was a little experiment that I was doing. As you must have read from a comment from Jonathan, it is not trivial to find the full method hierarchy. It found myself like building a JIT compiler myself so I left it there and will not be updating that tool. I am hoping to update SequenceViz to fix any bugs and add any enhancements.

If you are looking for a professional tool with similar features, try NDepend from Patrick Smacchia.

See this post for introduction to MethodViz.

Briefly "MethodViz is a simple method hierarchy visualizer. It lets you see the method tree from a particular method."

The latest release fixes the following issues:

* Unable to parse Generics
* Unable to detect Method overloads

Download Here

For those, who don't like Python or IronPython, here is a pure C# version of Method Visualizer.  The following screenshot shows it in action.

Here is a brief description about MethodViz:

MethodViz is a simple method hierarchy visualizer. It lets you see the method tree from a particular method.

Let's see this with an example.

This is a simple diagram for a case where PublicMethod( ) is calling Help( ) which is then calling HelpMeToo( ). You can see that the root methods and the other methods are from different classes.

For more detailed description, see the following blog posts:

Currently MethodViz supports the following type of method calls.

Normal Calls:

Described above.

Interface Calls:

Similarly, it will detect the correct instance even if you are calling from an interface or an abstract. I'll leave the "How" section to another blog post.

public void CheckDraw()
            IShape d = new RectangleShape();
            IShape d2 = new CircleShape();

Here IShape is an interface which is used to called the concrete implementations.  The following is the generated graph for the above method.

Although not shown above, but the Draw( ) methods for each concrete implementation are calling another method as clear by the diagram.

Abstract Classes:

Similar to the interfaces, the abstract classes are also mapped clearly.

public void CheckAbstractImplementation( )
            AbsClass ab = new AbsClassImpl();

In the above method, AbsClass is an abstract class where AbsClassImpl is the concrete implementation. Note that MethodImpl( ) is implemented by AbsClass whereas MethodNotImpl( ) is implemented by AbsClassImpl. Let's see how the diagram looks like.

Note the Class names highlighted by the red marker.

Cross Assembly Calls:

Another thing that it does it to automatically resolve assembly references ( * ) and connect those methods.

public void CrossAssemblyCall( )
            CecilSecondCase.CSCTypeA newObject = new CecilSecondCase.CSCTypeA();

The above method creates an instance of CSCTypeA class which is in CecilSecondCase.dll assembly. (Shown below)

public class CSCTypeA
        public void HelloWorld( )

        private void SayHello(string msg)
            CTCTypeA thirdCase = new CTCTypeA();

This class in turn create an instance of CTCTypeA which resides in the CecilThirdCase.dll assembly (Not showing here as it is similar to CSCTypeA). Hence the flow looks like this:

Main Assembly -> CecilSecondCase -> CecilThirdCase

The final diagram for the above method tree looks like this:

(Marker is only used to clear the point)

( * ) There are some restrictions as it only tries in the current directory for the assembly with the dll extension only.


The current release is like an alpha version of MethodViz. You may get incomplete graphs for some methods. In that case, you can check the log file generated in the exe directory.

The only known issue is no support for Generic method calls. So if your method contains a call to a generic method then this will definitely fail. You can just Continue there instead of Quit to check the other methods. It fails due to the IL representation of Generic method call.

newobj instance void CecilCase.Stack`1<int32>::.ctor()

This is a call to create a new object of a generic Stack. It blows up when the name is converted to XML and passed to XMLVisualizer to render because of invalid characters in XML. 

update: FIX the above issue with generics. The same download link will get the updated source and binaries. 

Download And Usage:

Download Here
The download contains the source and the binaries.

To try this, just extract is anywhere you like. You can start by running the "FrontEnd.exe" file in the bin\Debug folder. Once you see the window, you can open an assembly by click File -> Open Assembly. For playing with this, you can select "CecilCase.dll" which you'll find in the same directory and try out different methods.


I would really appreciate if you try this and see what works and what not. And also give your suggestions to include anything you like to see.

Talking about Digipede Grid Technology

Demo of building a Grid with Digipede

Nokia N95 looks cool but 12 Tips before you buy Nokia N95

What Haskell teaches us about writing Enterprise-scale software
(Same for Erlang)

"Enough of Processes" or the Ascendancy of the "Toolbox" approach

This is funny
Open Source coders caught stealing Open Source code

More Posts Next page »