This is a new experimental Reflector Add-In that will be part of the upcoming Reflector.Graph addin (see Assembly Grapher and Il Grapher). The objective of this addin is to rank methods using a method similar to google.
The graph
Consider a graph where the vertices are the methods of the classes, and each edge represents the fact that the source method calls the target method. For example, take the following dummy class:
public class Test
{
public void Hello()
{...}
public void HelloWorld()
{
this.Hello();
}
}
The method graph from this class will contain
- 2 vertices: Test.Hello and Test.HelloWorld
- 1 edge: Test.HelloWorld -> Test.Hello.
PageRank, The Algorithm
PageRank, which is the algorithm that Google uses to rank pages, is a well known and easy to implement algorithm (it is implemented in QuickGraph). The idea behing is very simple and elegant: important pages are reference by other important pages. So basically, PageRank algorithms can help you order the vertices of your graph by order of importance.
PageRank and MethodRank
Contrary to Google, where the vertices are pages and edges are the hyperlinks, the vertices are methods. However, the PageRank idea translates naturally to the method graph: important methods are called by other important methods. Why would we need to know which are the important vertices ? Here are my intuition (not tested) about this:
- if a important method contains a bug, it is likely that a lot of test cases will fail, (this a BIG assumption)
- using the previous point, it is clear that important methods are a good target for mutation testing,
- if you have to start testing, it can give you a "test writting" order,
- it's fun
The AddIn
for the pleasure of the eyes
