I have been pulling my hair out trying to solve this. What I am attempting to do is to build a 'map' of how objects are being used in a bit of code I am working on. Think of it as an enhanced Find Usages. The easiest way to show this is by example:
public class MasterClass
{
Type1 type1;
Type2 type2;
Type3 type3;
void InitializeData()
{
type1 = new Type1(this);
type2 = new Type2(this);
type3 = new Type3(this);
}
}
public class Type1
{
private MasterClass _master;
public Type1(MasterClass master)
{
_master = master;
}
public void Something()
{
//use _master.type2 and _master.type3 here
}
}
public class Type2
{
private MasterClass _master;
public Type2(MasterClass master)
{
_master = master;
}
public void Something()
{
//use _master.type3 here
}
}
public class Type3
{
private MasterClass _master;
public Type3(MasterClass master)
{
_master = master;
}
public void Something()
{
//use _master.type1 and _master.type2 here
}
}
What I am trying to do is get a mapping or report that, in the example's case, would give something like:
Type1 used by: {Type3}
Type2 used by: {Type1, Type3}
Type3 used by: {Type1, Type2}
If I can get it into a dictionary then I am home. :-)
What I've tried:
I have tried going over the assemblies, each type, each method then pulling the IL arrays and then trying to parse the operands with no luck. I have even tried going over the source files with some regular expressions but I have thousands of classes to go over, written in several different styles which means I will missed some references.
I can use Reflector &&/|| Resharper to get a single reference at a time but I would like to get them all at once.
Any suggestions?