From 423e553c6aa8427be1f2d12bac48a88be693f42c Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 4 Aug 2019 11:34:26 +0200 Subject: [PATCH] Fix #545: Add hyperlink to ctor method on parentheses in attributes --- .../CSharp/Syntax/TypeSystemAstBuilder.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs index 901a1149e..2e3009fa3 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs @@ -527,12 +527,18 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax { Attribute attr = new Attribute(); attr.Type = ConvertAttributeType(attribute.AttributeType); - SimpleType st = attr.Type as SimpleType; - MemberType mt = attr.Type as MemberType; - if (st != null && st.Identifier.EndsWith("Attribute", StringComparison.Ordinal)) { - st.Identifier = st.Identifier.Substring(0, st.Identifier.Length - 9); - } else if (mt != null && mt.MemberName.EndsWith("Attribute", StringComparison.Ordinal)) { - mt.MemberName = mt.MemberName.Substring(0, mt.MemberName.Length - 9); + switch (attr.Type) { + case SimpleType st: + if (st.Identifier.EndsWith("Attribute", StringComparison.Ordinal)) + st.Identifier = st.Identifier.Substring(0, st.Identifier.Length - 9); + break; + case MemberType mt: + if (mt.MemberName.EndsWith("Attribute", StringComparison.Ordinal)) + mt.MemberName = mt.MemberName.Substring(0, mt.MemberName.Length - 9); + break; + } + if (AddResolveResultAnnotations && attribute.Constructor != null) { + attr.AddAnnotation(new MemberResolveResult(null, attribute.Constructor)); } var parameters = attribute.Constructor?.Parameters ?? EmptyList.Instance; for (int i = 0; i < attribute.FixedArguments.Length; i++) {