internal void OnAssemblyLoaded(Assembly assembly) { foreach (var module in assembly.GetModules()) { NamespaceTree tree = new NamespaceTree(); tree.Add(module.GetMetadataTables()); ObjectModule.AddClrModules(tree.Root); } }
private static void DumpTables( IEnumerable <MetadataTables> allTables, bool dumpPE, bool dumpModule, bool dumpStatistics, bool dumpNamespaces, bool dumpExtensionMethods, bool dumpNestedTypes, bool dumpMembers, bool dumpMemberDetails) { var tree = new NamespaceTree(); foreach (MetadataTables tables in allTables) { #if DEBUG && CCI if (dumpPE && !tables.AssemblyDef.Record.IsNull) { tables.Dump(_output); } #endif if (dumpModule) { DumpModule(tables); } if (dumpNestedTypes) { _output.WriteLine("Nested types in {0}", MdTablesToString(tables)); DumpNestedTypes(tables); } if (dumpExtensionMethods) { _output.WriteLine("Extension methods in {0}", MdTablesToString(tables)); DumpExtensionMethods(tables); } if (dumpMembers) { _output.WriteLine("Members"); Detailed = dumpMemberDetails; DumpMembers(tables); } if (dumpNamespaces) { tree.Add(tables); } } if (dumpStatistics) { Statistics(tree, true); } if (dumpNamespaces) { DumpNamespaceTree(tree.Root); } }
private static void DumpMemMappedAssemblies() { var tree = new NamespaceTree(); foreach (var file in Directory.GetFiles(Path.GetDirectoryName(typeof(object).Assembly.Location), "*.dll")) { try { tree.Add(MetadataTables.OpenFile(file)); _output.WriteLine(file); } catch { } } DumpNamespaceTree(tree.Root); Statistics(tree, true); }
private static void Enumerate(IEnumerable <MetadataTables> tables) { var tree = new NamespaceTree(); foreach (var moduleTables in tables) { EnumerateExtensionMethods(moduleTables); tree.Add(moduleTables); ModuleEnumerated(moduleTables); } Counter_Types += (from ns in tree.GetAllNamespaces() from t in ns.GetTypeDefs() select 1).Count(); }
private static void Statistics(NamespaceTree tree, bool dump) { var x = from ns in tree.GetAllNamespaces() let count = ns.GetTypeDefs().Count() group ns by count into g let gCount = g.Count() orderby g.Key descending select new { Size = g.Key, Count = gCount }; foreach (var p in x) { if (dump) { _output.WriteLine("{0}\t{1}", p.Size, p.Count); } } Counter_Types = x.Sum((a) => a.Size); if (dump) { _output.WriteLine("Namespace size: total {0}, avg {1}", Counter_Types, x.Average((a) => a.Size)); } }
private static void Enumerate(IEnumerable<MetadataTables> tables) { var tree = new NamespaceTree(); foreach (var moduleTables in tables) { EnumerateExtensionMethods(moduleTables); tree.Add(moduleTables); ModuleEnumerated(moduleTables); } Counter_Types += (from ns in tree.GetAllNamespaces() from t in ns.GetTypeDefs() select 1).Count(); }
private static void DumpTables( IEnumerable<MetadataTables> allTables, bool dumpPE, bool dumpModule, bool dumpStatistics, bool dumpNamespaces, bool dumpExtensionMethods, bool dumpNestedTypes, bool dumpMembers, bool dumpMemberDetails) { var tree = new NamespaceTree(); foreach (MetadataTables tables in allTables) { #if DEBUG && CCI if (dumpPE && !tables.AssemblyDef.Record.IsNull) { tables.Dump(_output); } #endif if (dumpModule) { DumpModule(tables); } if (dumpNestedTypes) { _output.WriteLine("Nested types in {0}", MdTablesToString(tables)); DumpNestedTypes(tables); } if (dumpExtensionMethods) { _output.WriteLine("Extension methods in {0}", MdTablesToString(tables)); DumpExtensionMethods(tables); } if (dumpMembers) { _output.WriteLine("Members"); Detailed = dumpMemberDetails; DumpMembers(tables); } if (dumpNamespaces) { tree.Add(tables); } } if (dumpStatistics) { Statistics(tree, true); } if (dumpNamespaces) { DumpNamespaceTree(tree.Root); } }