Beispiel #1
0
        protected bool TryLookup(string assemblyPath, Guid mvid, uint tokenID, out string typeName)
        {
            LoadAssembly(assemblyPath);

            if (tokenID == 0)
            {
                typeName = String.Empty;
                return(false);
            }

            string key = GetTypeKey(assemblyPath, mvid, tokenID);

            typeName = String.Empty;
            if (types.TryGetValue(key, out string?name))
            {
                typeName = name ?? String.Empty;
                return(true);
            }

            if (!AlreadyWarned.Contains(key))
            {
                Log.Warning($"Type with token ID {tokenID} ({tokenID:X08}) not found in {assemblyPath}");
                AlreadyWarned.Add(key);
            }

            return(false);
        }
Beispiel #2
0
        public string Lookup(string assemblyName, Guid mvid, uint tokenID)
        {
            if (tokenID == 0)
            {
                return("[name unknown]");
            }

            string?assemblyPath = null;

            if (!AssemblyPaths.TryGetValue(assemblyName, out assemblyPath))
            {
                assemblyPath = FindAssembly(assemblyName);
                if (!String.IsNullOrEmpty(assemblyPath))
                {
                    AssemblyPaths.Add(assemblyName, assemblyPath);
                }
            }

            if (!String.IsNullOrEmpty(assemblyPath))
            {
                if (TryLookup(assemblyPath, mvid, tokenID, out string typeName))
                {
                    return(typeName);
                }
            }
            else if (!AlreadyWarned.Contains(assemblyName))
            {
                Log.Warning($"Assembly {assemblyName} cannot be found");
                AlreadyWarned.Add(assemblyName);
            }

            return($"[token id: {tokenID}]");
        }