Solved

Program counting classes and methods in C# files

Posted on 2008-10-08
4
230 Views
Last Modified: 2013-12-17
Hello,

do you know about some program that takes as the input some Solution in .Net (many C# files in projects), and the output is some chart of most frequently used classes (were instantiated many times) and methods (were callsed many times).

e.g.

ranking | method name | number of calls
1             method1()         2045
2             hello()                191
3             yes()                   3

thanks
0
Comment
Question by:xRalf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 26

Assisted Solution

by:Anurag Thakur
Anurag Thakur earned 240 total points
ID: 22670990
dont really know of any such tool but what you can do is get the information for one assembly
you can use reflection to load the assemnbly at run time and then can find all the types in the assembly their methods etc
http://www.dotnetspider.com/resources/19318-Reflection-C.aspx
http://articles.directorym.net/_NET_Tip_Display_Public_Information_for_an_Assembly-a923981.html
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 260 total points
ID: 22671046
I don't think reflection will help too much here as what he seems to be asking for is how often the calls were made at runtime... unless I am mistaken (there is no way to find out how many times an object will be instantiated at runtime by analyzing source code, just how many times it will be instantiated).


For this I would recommend (costs money) ants profiler http://www.red-gate.com/Products/ants_profiler/index.htm
or free CLR Profiler http://msdn.microsoft.com/en-us/netframework/aa569269.aspx

Both use the profiler API to access this information.


If you are just looking for source analysis there is a great product out there called ndepend http://www.ndepend.com/ that will do all that you are asking and a *whole* lot more.

Cheers,

Greg Young
0
 
LVL 6

Author Comment

by:xRalf
ID: 22672826
Thanks both a lot, I haven't thought about profiling at runtime but I'm blad that you expanded my question...
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 22672873
also ragi... to look for instantiations/method calls etc you would actually have to start parsing IL not just use reflections ... this is not actually too tough to do if you are familiar with IL but is non-trivial for most.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question