Browse Source

Print a custom attribute's positional arguments.

pull/52/head
Artur Zgodziski 15 years ago
parent
commit
7e5e94534c
  1. 6
      ICSharpCode.Decompiler/Ast/AstBuilder.cs
  2. 6
      ICSharpCode.Decompiler/Tests/CustomAttributes.cs
  3. 2
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Attribute.cs

6
ICSharpCode.Decompiler/Ast/AstBuilder.cs

@ -578,10 +578,14 @@ namespace Decompiler
foreach (var customAttribute in customAttributeProvider.CustomAttributes) foreach (var customAttribute in customAttributeProvider.CustomAttributes)
{ {
ICSharpCode.NRefactory.CSharp.Attribute attribute = new ICSharpCode.NRefactory.CSharp.Attribute(); ICSharpCode.NRefactory.CSharp.Attribute attribute = new ICSharpCode.NRefactory.CSharp.Attribute();
//customAttribute.
attribute.Type = ConvertType(customAttribute.AttributeType); attribute.Type = ConvertType(customAttribute.AttributeType);
section.Attributes.Add(attribute); section.Attributes.Add(attribute);
foreach (var parameter in customAttribute.ConstructorArguments)
{
attribute.Arguments.Add(new PrimitiveExpression(parameter.Value));
}
} }
attributedNode.Attributes.Add(section); attributedNode.Attributes.Add(section);

6
ICSharpCode.Decompiler/Tests/CustomAttributes.cs

@ -9,7 +9,11 @@ public static class CustomAtributes
[Flags] [Flags]
public enum EnumWithFlag public enum EnumWithFlag
{ {
Item1, // Item1,
Item2 Item2
} }
[Obsolete("some message")]
public static void ObsoletedMethod()
{
}
} }

2
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Attribute.cs

@ -25,12 +25,14 @@
// THE SOFTWARE. // THE SOFTWARE.
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
namespace ICSharpCode.NRefactory.CSharp namespace ICSharpCode.NRefactory.CSharp
{ {
/// <summary> /// <summary>
/// Attribute(Arguments) /// Attribute(Arguments)
/// </summary> /// </summary>
[DebuggerDisplay("Attribute {Type}")]
public class Attribute : AstNode public class Attribute : AstNode
{ {
public override NodeType NodeType { public override NodeType NodeType {

Loading…
Cancel
Save