public static IMethod Import(this ICompilation compilation, ICorDebugFunction corFunction) { Module module = compilation.GetAppDomain().Process.GetModule(corFunction.GetModule()); if (module.IsDynamic || module.IsInMemory) { return(module.Assembly.GetTypeDefinition("", "UnknownDynamicType").Methods.First()); } var info = GetInfo(module.Assembly); uint functionToken = corFunction.GetToken(); var unresolvedMethod = info.GetMethodFromToken(functionToken); if (unresolvedMethod == null) { // The type containing this function wasn't loaded yet uint classToken = corFunction.GetClass().GetToken(); var definition = ToTypeDefinitionReference(module, classToken).Resolve(new SimpleTypeResolveContext(module.Assembly)).GetDefinition(); if (definition == null) { throw new InvalidOperationException("Could not find class for token " + classToken); } definition.Methods.ToList(); // enforce loading the methods so that they get added to the dictionary unresolvedMethod = info.GetMethodFromToken(functionToken); if (unresolvedMethod == null) { throw new InvalidOperationException("Could not find function with token " + functionToken); } } return(unresolvedMethod.Resolve(new SimpleTypeResolveContext(module.Assembly))); }