• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

Program counting classes and methods in C# files


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).


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

  • 2
2 Solutions
Anurag ThakurTechnical ManagerCommented:
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
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.


Greg Young
xRalfAuthor Commented:
Thanks both a lot, I haven't thought about profiling at runtime but I'm blad that you expanded my question...
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now