private RefTree GetRefTree(AssemblyDefinition assemblyDefinition) { var refTree = new RefTree(); foreach (var typeReference in assemblyDefinition.MainModule.GetTypeReferences()) { refTree.AddType(typeReference); } foreach (var memberReference in assemblyDefinition.MainModule.GetMemberReferences()) { var scope = memberReference.DeclaringType.Scope; if (scope == null) { continue; } if (scope.MetadataScopeType != MetadataScopeType.AssemblyNameReference) { continue; } refTree.AddMember(memberReference); } return(refTree); }
private void DumpToXml(RefTree refTree, string outputXml) { var document = new XDocument(); document.Add(new XElement("Assembly")); foreach (var asm in refTree.Assemblies.OrderBy(a => a.Key)) { Dump(document.Root, asm); } document.Save(OutputXml); }
private RefTree GetRefTree(AssemblyDefinition assemblyDefinition) { var refTree = new RefTree(); foreach (var memberReference in assemblyDefinition.MainModule.GetMemberReferences()) { if (memberReference.DeclaringType.IsArray) { continue; } if (memberReference.DeclaringType.Scope.MetadataScopeType != MetadataScopeType.AssemblyNameReference) { continue; } refTree.AddMember(memberReference); } return refTree; }
private void DumpToConsole(RefTree refTree) { Log(); foreach (var kvp in refTree.Assemblies.OrderBy(a => a.Key)) { if (FilterToAssembly != null && kvp.Key.IndexOf(FilterToAssembly, StringComparison.OrdinalIgnoreCase) == -1) { continue; } Log(kvp.Key + ":", ConsoleColor.Cyan); if (OutputTypes || OutputMembers) { foreach (var typeRef in kvp.Value.Types.OrderBy(t => t.Key)) { var text = " " + typeRef.Key; if (OutputMembers) { PrintWithHighlight(text, text.LastIndexOf('.'), ConsoleColor.DarkGreen, ConsoleColor.Green); foreach (var memberRef in typeRef.Value.Members.OrderBy(m => m.FullName)) { text = " " + memberRef.FullName; PrintWithHighlight(text, text.LastIndexOf('.'), ConsoleColor.Gray, ConsoleColor.White); } } else { PrintWithHighlight(text, text.LastIndexOf('.'), ConsoleColor.DarkGray, ConsoleColor.Gray); } } Log(); } } }