I have an existing project where I would like to find out all calls being made and maybe dump into a log file.
I had a look at this thread, but didnt help much. I tried PostSharp, and the example shows how to achieve it. But I need to add an attribute to every darn method. Being an existing project, with in-numerous methods that is not a feasible option.
Is there any other means by which I can quickly trace all calls made?
Use a Profiler in tracing mode. Then you will see how everything does call each other and where the time is spent. Besides commercial profilers there are also free ones. For managed code there is NP Profiler which is quite good.
If you want to go deeper you can use the Windows Performance Toolkit which gives you full information accross all threads and how the interact with each other if you want to know. The only difference is that you get stacks ranging from kernel until your managed frames.
If this is not enough you can instrument your code with a tracing library (either automatically with PostSharp, ....) or manually or with a macro for each source file. I have made a little tracing library which is quite fast and highly configurable. See here. As unique feature it can trace any thrown exception automatically.
Here comes the output:
PostSharp certainly offers a way to apply an aspect to several targets without decorating them with attributes explicitly. See Multicast attributes.
When developing (multicast) aspect you must specify its usage:
And then apply the aspect in a way that covers your use case (eg. all public members in AdventureWorks.BusinessLayer namespace):
You can do this with Unity Interception
See this article for a sample. The article uses attributes, but my code sample below use the dependency injection system (coding to an interface) to setup interception.
If you want to log
MyClass
, it goes something like this:MyClass
=>IMyClass
IMatchingRule
.Code: