diff --git a/ICSharpCode.Decompiler/Ast/AstBuilder.cs b/ICSharpCode.Decompiler/Ast/AstBuilder.cs index 250bb400e..c1f04e348 100644 --- a/ICSharpCode.Decompiler/Ast/AstBuilder.cs +++ b/ICSharpCode.Decompiler/Ast/AstBuilder.cs @@ -73,28 +73,35 @@ namespace ICSharpCode.Decompiler.Ast if (settings.AnonymousMethods && method.Name.StartsWith("<", StringComparison.Ordinal) && method.IsCompilerGenerated()) return true; } + TypeDefinition type = member as TypeDefinition; - if (type != null && type.DeclaringType != null) { - if (settings.AnonymousMethods && type.Name.StartsWith("<>c__DisplayClass", StringComparison.Ordinal) && type.IsCompilerGenerated()) - return true; - if (settings.YieldReturn && YieldReturnDecompiler.IsCompilerGeneratorEnumerator(type)) - return true; - } else if (type != null && type.IsCompilerGenerated()) { - if (type.Name.StartsWith("", StringComparison.Ordinal)) - return true; - if (type.IsAnonymousType()) - return true; + if (type != null) { + if (type.DeclaringType != null) { + if (settings.AnonymousMethods && type.Name.StartsWith("<>c__DisplayClass", StringComparison.Ordinal) && type.IsCompilerGenerated()) + return true; + if (settings.YieldReturn && YieldReturnDecompiler.IsCompilerGeneratorEnumerator(type)) + return true; + } else if (type.IsCompilerGenerated()) { + if (type.Name.StartsWith("", StringComparison.Ordinal)) + return true; + if (type.IsAnonymousType()) + return true; + } } + FieldDefinition field = member as FieldDefinition; - if (field != null && field.IsCompilerGenerated()) { - if (settings.AnonymousMethods && field.Name.StartsWith("CS$<>", StringComparison.Ordinal)) - return true; - if (settings.AutomaticProperties && field.Name.StartsWith("<", StringComparison.Ordinal) && field.Name.EndsWith("BackingField", StringComparison.Ordinal)) + if (field != null) { + if (field.IsCompilerGenerated()) { + if (settings.AnonymousMethods && field.Name.StartsWith("CS$<>", StringComparison.Ordinal)) + return true; + if (settings.AutomaticProperties && field.Name.StartsWith("<", StringComparison.Ordinal) && field.Name.EndsWith("BackingField", StringComparison.Ordinal)) + return true; + } + // event-fields are not [CompilerGenerated] + if (settings.AutomaticEvents && field.DeclaringType.Events.Any(ev => ev.Name == field.Name)) return true; } - // event-fields are not [CompilerGenerated] - if (field != null && settings.AutomaticEvents && field.DeclaringType.Events.Any(ev => ev.Name == field.Name)) - return true; + return false; }