Possible Duplicate:
How can I add a Trace() to every method call in C#?
In the following example, Im inserting debug info inside each methods so that I can
see which function is called:
namespace A
{
class A1
{
void f1()
{
Console.WriteLine("inside A.A1.f1"); //1
}
void f2()
{
Console.WriteLine("inside A.A1.f2"); //2
}
}
}
There are hundreds of methods under different namespaces and classes.
Inserting debug messages one by one into each method is cumbersome and waste of time.
Instead of inserting method specific debug messages as above
is there better way to do it?
Maybe an API function that can tell which method Im in?
If you were using VS 2012, I would tell you to use Caller Information in your
WriteLine.Unfortunately in VS2010 this is not possible. You could call something like this but it would really not be performant: