2

Is it possible to find all uses of a class in an assembly?

[Test]
public void Test()
{
    var numUsages = FindUsages(typeof(MyDeprecatedType),typeof(MyDeprecatedType).Assembly);
    Assert.LessOrEqual(expectedNumUsages, numUsages);
}

public static int FindUsages(Type type, Assembly assembly)
{
    return //Num usages of deprecated type
}
svick
  • 236,525
  • 50
  • 385
  • 514
Steven Wexler
  • 16,589
  • 8
  • 53
  • 80

1 Answers1

0

You can do it with reflection only by looking into metadata and interpret method body enable through methodbase.getmethodbody.

http://msdn.microsoft.com/fr-fr/library/system.reflection.methodbase.getmethodbody%28v=vs.110%29.aspx

You can read method body like this:

http://www.codeproject.com/Articles/14058/Parsing-the-IL-of-a-Method-Body

Teter28
  • 504
  • 5
  • 8