Browse Source

support for type arguments of custom attributes.

pull/52/head
Artur Zgodziski 15 years ago
parent
commit
9f1eb2b4cd
  1. 7
      ICSharpCode.Decompiler/Ast/AstBuilder.cs
  2. 45
      ICSharpCode.Decompiler/Tests/CustomAttributes/CustomAttributeSamples.cs

7
ICSharpCode.Decompiler/Ast/AstBuilder.cs

@ -609,6 +609,13 @@ namespace Decompiler @@ -609,6 +609,13 @@ namespace Decompiler
{
parameterValue = MakePrimitive(Convert.ToInt64(parameter.Value), parameter.Type);
}
else if (parameter.Value is TypeReference)
{
parameterValue = new TypeOfExpression()
{
Type = ConvertType((TypeReference)parameter.Value),
};
}
else
{
parameterValue = new PrimitiveExpression(parameter.Value);

45
ICSharpCode.Decompiler/Tests/CustomAttributes/CustomAttributeSamples.cs

@ -38,6 +38,22 @@ namespace AttributeWithStringExpressionArgument @@ -38,6 +38,22 @@ namespace AttributeWithStringExpressionArgument
{
}
}
//$$ AttributeWithTypeArgument
namespace AttributeWithTypeArgument
{
[AttributeUsage(AttributeTargets.All)]
public class MyTypeAttribute : Attribute
{
public MyTypeAttribute(Type t)
{
}
}
[MyType(typeof(Attribute))]
public class SomeClass
{
}
}
//$$ AttributeAppliedToEvent (ignored)
namespace AttributeAppliedToEvent
{
@ -64,6 +80,24 @@ namespace AttributeAppliedToField @@ -64,6 +80,24 @@ namespace AttributeAppliedToField
public int Field;
}
}
//$$ AttributeAppliedToProperty
namespace AttributeAppliedToProperty
{
public class TestClass
{
[Obsolete("reason")]
public int Property
{
get
{
return 0;
}
}
}
}
//$$ AttributeAppliedToDelegate
[Obsolete("reason")]
public delegate int AttributeAppliedToDelegate();
//$$ AttributeAppliedToMethod
namespace AttributeAppliedToMethod
{
@ -79,6 +113,17 @@ namespace AttributeAppliedToMethod @@ -79,6 +113,17 @@ namespace AttributeAppliedToMethod
}
}
}
//$$ AttributeAppliedToInterface
[Obsolete("reason")]
public interface AttributeAppliedToInterface
{
}
//$$ AttributeAppliedToStruct
[Obsolete("reason")]
public struct AttributeAppliedToStruct
{
public int Field;
}
//$$ NamedParameter
namespace NamedParameter
{

Loading…
Cancel
Save