/// <summary>
        /// Resolves the type reference within the context of the given PE file.
        /// </summary>
        /// <returns>Either TypeDefinitionHandle, if the type is defined in the module or ExportedTypeHandle,
        /// if the module contains a type forwarder. Returns a nil handle, if the type was not found.</returns>
        public EntityHandle ResolveInPEFile(PEFile module)
        {
            string[] parts = typeName.Split('.');
            for (int i = parts.Length - 1; i >= 0; i--)
            {
                string ns           = string.Join(".", parts, 0, i);
                string name         = parts[i];
                int    topLevelTPC  = (i == parts.Length - 1 ? typeParameterCount : 0);
                var    topLevelName = new TopLevelTypeName(ns, name, topLevelTPC);
                var    typeHandle   = module.GetTypeDefinition(topLevelName);

                for (int j = i + 1; j < parts.Length && !typeHandle.IsNil; j++)
                {
                    int    tpc        = (j == parts.Length - 1 ? typeParameterCount : 0);
                    var    typeDef    = module.Metadata.GetTypeDefinition(typeHandle);
                    string lookupName = parts[j] + (tpc > 0 ? "`" + tpc : "");
                    typeHandle = typeDef.GetNestedTypes().FirstOrDefault(n => IsEqualShortName(n, module.Metadata, lookupName));
                }

                if (!typeHandle.IsNil)
                {
                    return(typeHandle);
                }
                FullTypeName typeName = topLevelName;
                for (int j = i + 1; j < parts.Length; j++)
                {
                    int tpc = (j == parts.Length - 1 ? typeParameterCount : 0);
                    typeName = typeName.NestedType(parts[j], tpc);
                }

                var exportedType = module.GetTypeForwarder(typeName);
                if (!exportedType.IsNil)
                {
                    return(exportedType);
                }
            }

            return(default);