Exemple #1
0
        private static void DumpNestedTypes(TypeNestings nesting, int level, IEnumerable <TypeDef> enclosing)
        {
            string indent = new String('\t', level);

            foreach (var enc in enclosing)
            {
                int count;
                var nested = nesting.GetNestedTypes(enc, out count);
                if (count > 0)
                {
                    _output.WriteLine("{0}{1}: {2}", indent, enc.Name, count);
                    DumpNestedTypes(nesting, level + 1, nested);
                }
                else
                {
                    _output.WriteLine("{0}{1}", indent, enc.Name);
                }
            }
        }
Exemple #2
0
        private static void DumpNestedTypes(MetadataTables tables)
        {
            _output.WriteLine("Type nesting: ");

            TypeNestings nesting = new TypeNestings(tables);

            _output.WriteLine("Total pairs: {0}",
                              (from e in nesting.GetEnclosingTypes()
                               from n in nesting.GetNestedTypes(e)
                               select 1).Sum()
                              );

            DumpNestedTypes(nesting, 0,
                            // top-level:
                            from TypeDef typeDef in nesting.GetEnclosingTypes()
                            where !typeDef.Attributes.IsNested()
                            select typeDef
                            );
        }
Exemple #3
0
 private static void DumpNestedTypes(TypeNestings nesting, int level, IEnumerable<TypeDef> enclosing)
 {
     string indent = new String('\t', level);
     foreach (var enc in enclosing) {
         int count;
         var nested = nesting.GetNestedTypes(enc, out count);
         if (count > 0) {
             _output.WriteLine("{0}{1}: {2}", indent, enc.Name, count);
             DumpNestedTypes(nesting, level + 1, nested);
         } else {
             _output.WriteLine("{0}{1}", indent, enc.Name);
         }
     }
 }
        public static TypeNestings GetTypeNesting(this MetadataTables tables)
        {
            if (TypeNestings == null) {
                TypeNestings = new Dictionary<MetadataTables, TypeNestings>();
            }

            lock (TypeNestings) {
                TypeNestings nestings;
                if (TypeNestings.TryGetValue(tables, out nestings)) {
                    nestings = new TypeNestings(tables);
                }
                return nestings;
            }
        }
Exemple #5
0
        private static void DumpNestedTypes(MetadataTables tables)
        {
            _output.WriteLine("Type nesting: ");

            TypeNestings nesting = new TypeNestings(tables);

            _output.WriteLine("Total pairs: {0}",
                (from e in nesting.GetEnclosingTypes()
                 from n in nesting.GetNestedTypes(e)
                 select 1).Sum()
            );

            DumpNestedTypes(nesting, 0,
                // top-level:
                from TypeDef typeDef in nesting.GetEnclosingTypes()
                where !typeDef.Attributes.IsNested()
                select typeDef
            );
        }