Solved

Program counting classes and methods in C# files

Posted on 2008-10-08
4
221 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
  • 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

785 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