From 7e5e94534ce24e0d3fd27d2d28337af18c1f84e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20Zgodzi=C5=84ski?= Date: Wed, 23 Feb 2011 17:42:36 +0100 Subject: [PATCH] Print a custom attribute's positional arguments. --- ICSharpCode.Decompiler/Ast/AstBuilder.cs | 6 +++++- ICSharpCode.Decompiler/Tests/CustomAttributes.cs | 6 +++++- .../CSharp/Ast/GeneralScope/Attribute.cs | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.Decompiler/Ast/AstBuilder.cs b/ICSharpCode.Decompiler/Ast/AstBuilder.cs index b4ed67ac3..3a30aae48 100644 --- a/ICSharpCode.Decompiler/Ast/AstBuilder.cs +++ b/ICSharpCode.Decompiler/Ast/AstBuilder.cs @@ -578,10 +578,14 @@ namespace Decompiler foreach (var customAttribute in customAttributeProvider.CustomAttributes) { ICSharpCode.NRefactory.CSharp.Attribute attribute = new ICSharpCode.NRefactory.CSharp.Attribute(); - //customAttribute. attribute.Type = ConvertType(customAttribute.AttributeType); section.Attributes.Add(attribute); + foreach (var parameter in customAttribute.ConstructorArguments) + { + attribute.Arguments.Add(new PrimitiveExpression(parameter.Value)); + } + } attributedNode.Attributes.Add(section); diff --git a/ICSharpCode.Decompiler/Tests/CustomAttributes.cs b/ICSharpCode.Decompiler/Tests/CustomAttributes.cs index fa12ffa9b..17f1a55ed 100644 --- a/ICSharpCode.Decompiler/Tests/CustomAttributes.cs +++ b/ICSharpCode.Decompiler/Tests/CustomAttributes.cs @@ -9,7 +9,11 @@ public static class CustomAtributes [Flags] public enum EnumWithFlag { - Item1, +// Item1, Item2 } + [Obsolete("some message")] + public static void ObsoletedMethod() + { + } } diff --git a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Attribute.cs b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Attribute.cs index 877771736..b5a44275b 100644 --- a/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Attribute.cs +++ b/NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Attribute.cs @@ -25,12 +25,14 @@ // THE SOFTWARE. using System.Collections.Generic; +using System.Diagnostics; namespace ICSharpCode.NRefactory.CSharp { /// /// Attribute(Arguments) /// + [DebuggerDisplay("Attribute {Type}")] public class Attribute : AstNode { public override NodeType NodeType {