예제 #1
0
        public IEnumerable<TypeDef> GetNestedTypes(TypeDef typeDef, out int count)
        {
            ContractUtils.Requires(((MetadataRecord)typeDef).Tables.Equals(_tables));

            List<MetadataToken> nestedList;
            if (_mapping.TryGetValue(typeDef.Record.Token, out nestedList)) {
                count = nestedList.Count;
                return from nested in nestedList select _tables.GetRecord(nested).TypeDef;
            }

            count = 0;
            return _EmptyTypeDefs;
        }
예제 #2
0
 public IEnumerable<TypeDef> GetNestedTypes(TypeDef typeDef)
 {
     int count;
     return GetNestedTypes(typeDef, out count);
 }
예제 #3
0
 internal void AddType(TypeDef typeDef)
 {
     if (_typeDefs == null) {
         _typeDefs = new List<TypeDef>();
     }
     _typeDefs.Add(typeDef);
 }
예제 #4
0
 internal ClrTypeInfo(TypeDef typeDef)
 {
     _typeDef = typeDef;
 }
예제 #5
0
파일: Program.cs 프로젝트: TerabyteX/main
        private static void DumpMembers(TypeDef typeDef)
        {
            int gpCount = typeDef.GetGenericParameterCount();

            _output.WriteLine("{0} {1}.{2}{3} : {4:X8}",
                ((typeDef.Attributes & TypeAttributes.Interface) != 0) ? "interface" : "type",
                typeDef.Namespace,
                typeDef.Name,
                gpCount > 0 ? "<#" + gpCount + ">" : null,
                TypeToString(typeDef.BaseType)
            );

            DumpGenericParameters(typeDef.GenericParameters, typeDef.Record);

            foreach (InterfaceImpl ifaces in typeDef.ImplementedInterfaces) {
                Debug.Assert(ifaces.ImplementingType.Record.Equals(typeDef.Record));
                _output.WriteLine("  implements {0}", TypeToString(ifaces.InterfaceType));
            }

            foreach (FieldDef fieldDef in typeDef.Fields) {
                var attrs = fieldDef.Attributes;
                _output.Write("  field      {0}", fieldDef.Name);
                if ((attrs & FieldAttributes.HasDefault) != 0) {
                    _output.Write(" = {0}", DefaultValueToString(fieldDef.GetDefaultValue()));
                }
                _output.WriteLine();

                if (Detailed) {
                    _output.WriteLine("    signature: {0}", SignatureToString(fieldDef.Signature));
                    _output.WriteLine("    attributes: {0}", fieldDef.Attributes);
                    DumpCustomAttributes(fieldDef.CustomAttributes, "    ");
                    MemoryBlock data = fieldDef.GetData(0);
                    if (data != null) {
                        // we would need to parse signature to get the size of the field's type:
                        _output.WriteLine("    data: {0}-...", MemoryToString(data, 5));
                    }
                }
                Debug.Assert(fieldDef.FindDeclaringType().Record.Equals(typeDef.Record));
            }

            foreach (MethodDef methodDef in typeDef.Methods) {
                _output.WriteLine("  method     {0}", methodDef.Name);

                if (Detailed) {
                    _output.WriteLine("    signature: {0}", SignatureToString(methodDef.Signature));
                    _output.WriteLine("    attributes: {0} {1}", methodDef.Attributes, methodDef.ImplAttributes);
                    DumpCustomAttributes(methodDef.CustomAttributes, "    ");
                    DumpGenericParameters(methodDef.GenericParameters, methodDef.Record);

                    foreach (ParamDef p in methodDef.Parameters) {
                        _output.WriteLine("    parameter #{0}: {1}", p.Index, p.Name);
                        Debug.Assert(p.FindDeclaringMethod().Record.Equals(methodDef));
                        DumpCustomAttributes(p.CustomAttributes, "    ");
                    }

                    MemoryBlock body = methodDef.GetBody();
                    if (body != null) {
                        _output.WriteLine("    body: {0}-...", MemoryToString(body, 5));
                    }
                }
                Debug.Assert(methodDef.FindDeclaringType().Record.Equals(typeDef.Record));
            }

            foreach (PropertyDef propertyDef in typeDef.Properties) {
                var attrs = propertyDef.Attributes;
                _output.Write("  property   {0} {{ ", propertyDef.Name);
                var accessors = propertyDef.GetAccessors();
                if (accessors.HasGetter) {
                    _output.Write("get: {0}; ", accessors.Getter.Name);
                }
                if (accessors.HasSetter) {
                    _output.Write("set: {0}; ", accessors.Setter.Name);
                }
                if ((attrs & PropertyAttributes.HasDefault) != 0) {
                    _output.Write("default: {0}; ", DefaultValueToString(propertyDef.GetDefaultValue()));
                }

                _output.WriteLine("}");

                if (Detailed) {
                    DumpCustomAttributes(propertyDef.CustomAttributes, "    ");
                }
                Debug.Assert(propertyDef.FindDeclaringType().Record.Equals(typeDef.Record));
            }

            foreach (EventDef eventDef in typeDef.Events) {
                _output.Write("  event      {0} {{ ", eventDef.Name);
                var accessors = eventDef.GetAccessors();
                if (accessors.HasAdd) {
                    _output.Write("add: {0}; ", accessors.Add.Name);
                }
                if (accessors.HasRemove) {
                    _output.Write("remove: {0}; ", accessors.Remove.Name);
                }
                if (accessors.HasFire) {
                    _output.Write("fire: {0}; ", accessors.Fire.Name);
                }
                _output.WriteLine("}");

                if (Detailed) {
                    DumpCustomAttributes(eventDef.CustomAttributes, "    ");
                }
                Debug.Assert(eventDef.FindDeclaringType().Record.Equals(typeDef));
            }

            _output.WriteLine();
        }