Browse Source

Fix hiding of mcs generated members

pull/307/head
Jb Evain 14 years ago
parent
commit
32584c07c8
  1. 19
      ICSharpCode.Decompiler/Ast/AstBuilder.cs

19
ICSharpCode.Decompiler/Ast/AstBuilder.cs

@ -70,14 +70,14 @@ namespace ICSharpCode.Decompiler.Ast
if (method != null) { if (method != null) {
if (method.IsGetter || method.IsSetter || method.IsAddOn || method.IsRemoveOn) if (method.IsGetter || method.IsSetter || method.IsAddOn || method.IsRemoveOn)
return true; return true;
if (settings.AnonymousMethods && method.Name.StartsWith("<", StringComparison.Ordinal) && method.IsCompilerGenerated()) if (settings.AnonymousMethods && IsGeneratedMemberName(method.Name) && method.IsCompilerGenerated())
return true; return true;
} }
TypeDefinition type = member as TypeDefinition; TypeDefinition type = member as TypeDefinition;
if (type != null) { if (type != null) {
if (type.DeclaringType != null) { if (type.DeclaringType != null) {
if (settings.AnonymousMethods && type.Name.StartsWith("<>c__DisplayClass", StringComparison.Ordinal) && type.IsCompilerGenerated()) if (settings.AnonymousMethods && IsGeneratedMemberName(type.Name) && type.IsCompilerGenerated())
return true; return true;
if (settings.YieldReturn && YieldReturnDecompiler.IsCompilerGeneratorEnumerator(type)) if (settings.YieldReturn && YieldReturnDecompiler.IsCompilerGeneratorEnumerator(type))
return true; return true;
@ -91,10 +91,10 @@ namespace ICSharpCode.Decompiler.Ast
FieldDefinition field = member as FieldDefinition; FieldDefinition field = member as FieldDefinition;
if (field != null) { if (field != null) {
if (field.IsCompilerGenerated()) { if (field.IsCompilerGenerated()) {
if (settings.AnonymousMethods && field.Name.StartsWith("CS$<>", StringComparison.Ordinal)) if (settings.AnonymousMethods && (IsGeneratedMemberName(field.Name) || field.Name.StartsWith("CS$<>", StringComparison.Ordinal)))
return true; return true;
if (settings.AutomaticProperties && field.Name.StartsWith("<", StringComparison.Ordinal) && field.Name.EndsWith("BackingField", StringComparison.Ordinal)) if (settings.AutomaticProperties && IsGeneratedMemberName(field.Name) && field.Name.EndsWith("BackingField", StringComparison.Ordinal))
return true; return true;
} }
// event-fields are not [CompilerGenerated] // event-fields are not [CompilerGenerated]
@ -104,6 +104,11 @@ namespace ICSharpCode.Decompiler.Ast
return false; return false;
} }
static bool IsGeneratedMemberName(string name)
{
return name.StartsWith("<", StringComparison.Ordinal);
}
/// <summary> /// <summary>
/// Runs the C# transformations on the compilation unit. /// Runs the C# transformations on the compilation unit.

Loading…
Cancel
Save