tags:

views:

62

answers:

3

I would like to implement a way to trace every line of code in an application that is written for .net v4.0.

An example would be. If I had the following function.

private bool hasValue(string value)
{
if(string.isnullorempty(value)
{
 return false; 
}
else
{
return true;
}}

Then when the function is called I want detailed trace logs to contain something like this:

Function called |Line 10 |Signature private bool hasValue(string value)|ValuesPassed hasValue("") Line Evaluated | Line 11 | if(string.isnullorempty(value) |ValuesPassed if(string.isnullorempty("") - evaluation returned true entered line 13 |signature return false|return action taken.

This tracing can be done manually, but its a lot of work, and would dirty the code. Isn't there a way to get this level of tracing automatically with .net or 3rd party plugin?

Thank you

+4  A: 

I don't know of any framework that would work for this sort of thing, but I'd like to counter with a few questions.

  1. What do you think the utility of such verbose tracing would be? It seems to me that a few targeted trace statements would suffice for most debugging problems.

  2. Is this tracing going to be used in a fielded solution? If so, it will probably be very expensive (in terms of time-to-execute) when enabled.

  3. How large is your application? Unless it's tiny, parsing the log files generated by your desired tracing solution might be MORE work than implementing some targeted tracing on your own.

Andrew Anderson
A: 

Although you will not be able to get line level tracing automatically, you can get method level tracing using Aspect Oriented Programming, where code can be weaved in post build at method entry\exit points. The code that you weave in can trace method names, parameter and values, ect. A tool like PostSharp can do this for you automatically:

http://www.sharpcrafters.com/

chibacity
A: 

Runtime Flow provides automatic function level tracing of .NET 4.0 applications.

Sergey Vlasov