Solved

Program counting classes and methods in C# files

Posted on 2008-10-08
4
216 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
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.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now