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
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/solutions/monitoring#tracing