private void GetReferencesFromFile(Stack <AssemblyName> newAssemblies, HashSet <AssemblyName> visitedAssemblies, string currentFile) { var assemblyObj = ResolvedAssemblyObject.CreateFrom(currentFile); AssemblyName[] refs = assemblyObj.GetAssemblyReferences(); foreach (var newFile in refs) { ResolvedAssemblyResultEnum resolveResult = TryResolveAssembly(newFile, out AssemblyName an); _assemblyLoadedDelegate?.Invoke(currentFile, resolveResult == ResolvedAssemblyResultEnum.NoMatch ? newFile : an, resolveResult); // If there is no match, move on to the next reference. if (resolveResult == ResolvedAssemblyResultEnum.NoMatch) { continue; } if (!new AssemblyNameComparer().Equals(newFile, an)) { // we loaded a different assembly than what the reference was saying. _assemblyVersionMismatchDelegate?.Invoke(newFile, an); // we overwrite the one that was loaded because the closure is based on what is referenced, not what we end up loading. newFile.CodeBase = an.CodeBase; an = newFile; } // if we haven't seen this already if (!visitedAssemblies.Contains(an)) { newAssemblies.Push(an); } } }
public static ReferencedTypeObject CreateFrom(ResolvedAssemblyObject ao, TypeReference typeRef, ResolveAssemblyDelegate resolveAssembly) { ReferencedTypeObject to = new ReferencedTypeObject(ao._fs, ao._peReader, ao._metaReader, typeRef, resolveAssembly); return(to); }
public static ReferencedTypeObject CreateFrom(ResolvedAssemblyObject ao, TypeReference typeRef) { return(CreateFrom(ao, typeRef, null)); }
public static ExportedTypeObject CreateFrom(ResolvedAssemblyObject ao, ExportedType exportedType, ResolveAssemblyDelegate resolveAssembly) { ExportedTypeObject to = new ExportedTypeObject(ao._fs, ao._peReader, ao._metaReader, exportedType, resolveAssembly); return(to); }
public static ExportedTypeObject CreateFrom(ResolvedAssemblyObject ao, ExportedType exportedType) { return(CreateFrom(ao, exportedType, null)); }
public static DeclaredTypeObject CreateFrom(ResolvedAssemblyObject ao, TypeDefinition typeDef) { DeclaredTypeObject to = new DeclaredTypeObject(ao._fs, ao._peReader, ao._metaReader, typeDef); to.Assembly = ao; return to; }