public static XElement DumpType(TypeDefinition type, bool dumpParents=false) { string typeType; if (type.IsInterface) typeType = "Interface"; else if (type.IsEnum) typeType = "Enum"; else if (type.IsValueType) typeType = "Struct"; else if (type.IsClass) typeType = "Class"; else typeType = "Type"; XElement typeXml = new XElement(typeType); typeXml.SetAttributeValue("Name", type.CorrectName()); if (type.IsClass && type.IsSealed && type.IsAbstract) { typeXml.SetAttributeValue("Static", "true"); } else if (type.IsClass && type.IsAbstract) { typeXml.SetAttributeValue("Abstract", "true"); } if (!type.IsNested) typeXml.SetAttributeValue("Path", type.Namespace); //adding fields foreach (FieldDefinition field in type.Fields.Where(f => f.IsPublic)) { XElement fieldXml = new XElement("Field"); fieldXml.SetAttributeValue("Name", field.Name); fieldXml.SetAttributeValue("Static", field.IsStatic ? "true" : null); if (type.IsEnum) { fieldXml.SetAttributeValue("Value", field.Constant); } else { fieldXml.SetAttributeValue("Type", field.FieldType); } typeXml.Add(fieldXml); } //adding methods foreach (MethodDefinition method in type.Methods.Where(m => m.IsPublic && !m.IsGetter && !m.IsSetter)) { typeXml.Add(DumpMethod(method)); } //adding properties foreach (PropertyDefinition property in type.Properties.Where(p => (p.GetMethod != null && p.GetMethod.IsPublic) || (p.SetMethod != null && p.SetMethod.IsPublic))) { XElement propertyXml = new XElement("Property"); propertyXml.SetAttributeValue("Name", property.Name); propertyXml.SetAttributeValue("Type", property.PropertyType); if (property.GetMethod != null && property.GetMethod.IsPublic) { propertyXml.Add(DumpMethod(property.GetMethod)); } if (property.SetMethod != null && property.SetMethod.IsPublic) { propertyXml.Add(DumpMethod(property.SetMethod)); } typeXml.Add(propertyXml); } //adding nested types foreach (TypeDefinition nestedType in type.NestedTypes.Where(m => m.IsNestedPublic)) { typeXml.Add(DumpType(nestedType)); } //adding members from parent types if(dumpParents && type.BaseType!=null) { XElement parentXml = DumpType(type.BaseType.Resolve(),true); foreach (XElement element in parentXml.Elements()) { if(typeXml.Elements().All(e=>!Check.AreCompatible(e,element))) { typeXml.Add(element); } } } return typeXml; }