Permalink
Browse files

Don't show the nested display classes when decompiling a complete type.

  • Loading branch information...
1 parent 4be02c0 commit 9f4830f44758049b08908d1368a0705efbb46010 @dgrunwald dgrunwald committed Feb 19, 2011
Showing with 15 additions and 11 deletions.
  1. +14 −1 ICSharpCode.Decompiler/Ast/AstBuilder.cs
  2. +1 −10 ILSpy/CSharpLanguage.cs
@@ -24,6 +24,17 @@ public AstBuilder(DecompilerContext context)
this.context = context;
}
+ public static bool MemberIsHidden(MemberReference member)
+ {
+ MethodDefinition method = member as MethodDefinition;
+ if (method != null && (method.IsGetter || method.IsSetter || method.IsAddOn || method.IsRemoveOn))
+ return true;
+ TypeDefinition type = member as TypeDefinition;
+ if (type != null && type.DeclaringType != null && type.Name.StartsWith("<>c__DisplayClass", StringComparison.Ordinal) && type.IsCompilerGenerated())
+ return true;
+ return false;
+ }
+
public void GenerateCode(ITextOutput output)
{
GenerateCode(output, null);
@@ -131,6 +142,8 @@ public TypeDeclaration CreateType(TypeDefinition typeDef)
// Nested types
foreach(TypeDefinition nestedTypeDef in typeDef.NestedTypes) {
+ if (MemberIsHidden(nestedTypeDef))
+ continue;
astType.AddChild(CreateType(nestedTypeDef), TypeDeclaration.MemberRole);
}
@@ -415,7 +428,7 @@ void AddTypeMembers(TypeDeclaration astType, TypeDefinition typeDef)
// Add methods
foreach(MethodDefinition methodDef in typeDef.Methods) {
- if (methodDef.IsSpecialName) continue;
+ if (methodDef.IsConstructor || MemberIsHidden(methodDef)) continue;
astType.AddChild(CreateMethod(methodDef), TypeDeclaration.MemberRole);
}
View
@@ -167,16 +167,7 @@ public override object VisitMemberType(MemberType memberType, object data)
public override bool ShowMember(MemberReference member)
{
- if (showAllMembers) {
- return true;
- }
- MethodDefinition method = member as MethodDefinition;
- if (method != null && (method.IsGetter || method.IsSetter || method.IsAddOn || method.IsRemoveOn))
- return false;
- TypeDefinition type = member as TypeDefinition;
- if (type != null && type.Name.StartsWith("<>c__DisplayClass", StringComparison.Ordinal) && type.IsCompilerGenerated())
- return false;
- return true;
+ return showAllMembers || !AstBuilder.MemberIsHidden(member);
}
}
}

0 comments on commit 9f4830f

Please sign in to comment.