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)));
        }
Exemple #2
0
        /// <summary>
        /// Gets the module.
        /// </summary>
        /// <returns></returns>
        public CorModule GetModule()
        {
            ICorDebugModule comodule;

            cofunc.GetModule(out comodule);
            return(new CorModule(comodule, options));
        }
        public CorFunction(ICorDebugFunction funtion)
        {
            corFunction = funtion;
            ICorDebugModule imodule = null;
            corFunction.GetModule(out imodule);
            module = new CorModule(imodule);
            corFunction.GetToken(out token);
            //corFunction.GetLocalVarSigToken(
            //ICorDebugFunctionBreakpoint breakPoint = null;

            //corFunction.
        }
		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));
		}