void GetVirtualMethods(AssemblyCache cache, HashSet <MethodKey> methods, TypeDefinition type)
{
// check the interfaces
foreach (var ifaceRef in type.Interfaces)
{
TypeDefinition iface = project.GetTypeDefinition(ifaceRef.InterfaceType);
// if it's not in the project, try to get it via the cache
if (iface == null)
{
iface = cache.GetTypeDefinition(ifaceRef.InterfaceType);
}
// search interface
if (iface != null)
{
GetVirtualMethods(cache, methods, iface);
}
}
// check the base type unless it isn't in the project, or we don't have one
TypeDefinition baseType = project.GetTypeDefinition(type.BaseType);
// if it's not in the project, try to get it via the cache
if (baseType == null)
{
baseType = cache.GetTypeDefinition(type.BaseType);
}
// search base
if (baseType != null)
{
GetVirtualMethods(cache, methods, baseType);
}
foreach (MethodDefinition method in type.Methods)
{
if (method.IsVirtual)
{
methods.Add(new MethodKey(method));
}
}
}