private TypeDesc FindType(CompilerTypeSystemContext context, string typeName) { ModuleDesc systemModule = context.SystemModule; TypeDesc foundType = systemModule.GetTypeByCustomAttributeTypeName(typeName, false, (typeDefName, module, throwIfNotFound) => { return (MetadataType)context.GetCanonType(typeDefName) ?? CustomAttributeTypeNameParser.ResolveCustomAttributeTypeDefinitionName(typeDefName, module, throwIfNotFound); }); if (foundType == null) throw new CommandLineException($"Type '{typeName}' not found"); return foundType; }
/// <summary> /// Given a parsed out module, namespace + type, and method name, try to find a matching MethodDesc /// TODO: We have no signature information for the method - what policy should we apply where multiple methods exist with the same name /// but different signatures? For now we'll take the first matching and ignore others. Ideally we'll improve the profile data to include this. /// </summary> /// <returns>MethodDesc if found, null otherwise</returns> private MethodDesc ResolveMethodName(CompilerTypeSystemContext context, ModuleDesc module, string namespaceAndTypeName, string methodName) { TypeDesc resolvedType = module.GetTypeByCustomAttributeTypeName(namespaceAndTypeName, false, (typeDefName, module, throwIfNotFound) => { return((MetadataType)context.GetCanonType(typeDefName) ?? CustomAttributeTypeNameParser.ResolveCustomAttributeTypeDefinitionName(typeDefName, module, throwIfNotFound)); }); if (resolvedType != null) { var resolvedMethod = resolvedType.GetMethod(methodName, null); if (resolvedMethod != null) { return(resolvedMethod); } } return(null); }