Click here to Skip to main content
Click here to Skip to main content
Go to top

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.

Introduction

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.

Background

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):

call_tree_left_side_2.png

call_tree_right_side_2.png

License

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

Share

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 VS2008 on Vista 64bit. Located near Lancaster, PA. e-mail: lklauder@wsof.com.

Comments and Discussions

 
GeneralBetter via assembly.. Pinmemberhughd11-Jan-09 1:14 
GeneralRe: Better via assembly.. [modified] PinmemberLouis T Klauder Jr11-Jan-09 2:53 
GeneralInteresting solution PinmvpColin Angus Mackay29-Dec-08 15:23 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 8 Jan 2009
Article Copyright 2008 by Louis T Klauder Jr
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid