Click here to Skip to main content
13,868,341 members
Click here to Skip to main content
Add your own
alternative version


29 bookmarked
Posted 29 Dec 2008
Licenced CPOL

Call tree for C# programs

, 8 Jan 2009
Rate this:
Please Sign up or sign in to vote.
A simple C# user function call tree lister.


The download offered here is a Visual Studio 2008 C# project for a simple utility to list user function call trees in C# code.

This call tree lister seems to work OK for my style of coding, but will likely be unreliable for some other styles of coding. It is offered here with two thoughts: first, some programmers may find it useful as is; second, I would be appreciative if someone who is up-to-speed on C# parsing would upgrade it by incorporating an accurate C# parser and turn out an improved utility that is reliable regardless of coding style.


Years ago, I used the SCO C compiler to put together a simple utility to show the call tree for user written functions in a code I was developing in the Progress language. When I subsequently installed a new release of the SCO C compiler, I was annoyed to discover that SCO had removed, from the compiler and its run time support, the simple in memory database that the compiler had previously provided so that my call tree lister no longer worked.

I recently felt a renewed need to be able to see call trees for my code. Upon searching on the web for something that would be easy to use, I came up empty. There are a few Linux and GNU utilities that are undoubtedly excellent and would be convenient for someone working in that world, but the overhead for me to set up that environment seemed too much for one of those offerings to be cost effective for me. I found one or two C# language parsers, but I am not into parsing, and again, the learning curve to work with one of those seemed disproportionate for what I wanted. So, I took a little time, and used .NET's Regular Expression class to develop the C# user function call tree lister offered in the download.

Using the Code

The executable in the \bin\debug directory can be run directly assuming that .NET 3.5 support is available. If you have Visual Studio 2008, you can run the project in the debugger, and it can probably be retargeted to an earlier version of .NET.

Each time you enter a root function in the “2nd:..” text box and then click the upper right corner button “3rd:..” to generate its tree you are prompted for the location and name of a file of type .call_tree for output of a copy of the call tree shown in the window. If you specify an existing .call_tree file the new tree is appended to that file.

Here is an example of what the user interface looks like (with the left side of the window shown first and the right side shown below, because CodeProject limits images to a width of 600 pixels):




This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Louis T Klauder Jr
Software Developer Track Shape & Use LLC
United States United States
Develop software for railroad track geometry engineering and track maintenance and some for rail vehicle performance. Dabble in big integers and prime numbers. Work in C# in Visual Studio. Located in Marshall, MI. e-mail:

You may also be interested in...

Comments and Discussions

GeneralBetter via assembly.. Pin
hughd11-Jan-09 2:14
memberhughd11-Jan-09 2:14 
GeneralRe: Better via assembly.. [modified] Pin
Louis T Klauder Jr11-Jan-09 3:53
professionalLouis T Klauder Jr11-Jan-09 3:53 
GeneralInteresting solution Pin
Colin Angus Mackay29-Dec-08 16:23
memberColin Angus Mackay29-Dec-08 16:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190214.1 | Last Updated 8 Jan 2009
Article Copyright 2008 by Louis T Klauder Jr
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid