Reputation: 3779
I have an application I need to analyze. I have the source code here. I already found a way to log the method calls using this code:
Inside Method: logger.MethodTraceLog();
public void MethodTraceLog()
{
var msg = "MethodTraceLog: "
+ this.log.Logger.Name
+ " ### "
+ new StackFrame(1).GetMethod().Name ;
this.log.Debug(msg);
}
Is there any way to "inject" the logging call into every method of a class, without having to rewrite the whole source code. As I said, I could, but it just is a lot of work. Some "post function call via reflection" in the constructor, or anything similar?
Thanks for tips... If anybody has some links additional for analyzing the "behaviour" of an application, I would not say no to it :-) Any framework out there? (Except breakpoints and a lot of F-Key hitting)
Upvotes: 0
Views: 2086
Reputation: 8804
Visual Studio Team System's Profiler tool, when running in instrumentation mode, can report back metrics like "Most Called Functions"
Performance Report Summary http://i.msdn.microsoft.com/aa718874.fig3(en-us).jpg
You may want to look into using this feature if it is included in your version of Visual Studio.
Upvotes: 0
Reputation: 161773
I recommend you do two things: one, get NDepend.
Two, get the Visual Studio 2010 beta 1. Run it in a VM if necessary. It will generate sequence diagrams from code, I believe, and has other features to help comprehend a code base at a high level. You don't have to use it for anything other than understanding.
The downside is that I hereby pass along to you the moral obligation to report bugs you find, on http://connect.microsoft.com/visualstudio.
:-)
Upvotes: 0
Reputation: 1033
Actually, there is a concept called Aspect Oriented Programming (AOP) and an implementation in c# called PostSharp (http://www.postsharp.org/) that allows you to inject code post compilation.
Upvotes: 4