Browse Source

attributed parameter declaration.

pull/52/head
Artur Zgodziski 15 years ago
parent
commit
75661da50e
  1. 1
      ICSharpCode.Decompiler/Ast/AstBuilder.cs
  2. 62
      ICSharpCode.Decompiler/Tests/CustomAttributes/CustomAttributeSamples.cs
  3. 2
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs
  4. 3
      NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs

1
ICSharpCode.Decompiler/Ast/AstBuilder.cs

@ -584,6 +584,7 @@ namespace Decompiler @@ -584,6 +584,7 @@ namespace Decompiler
}
// TODO: params, this
ConvertCustomAtributes(astParam, paramDef);
yield return astParam;
}
}

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

@ -54,8 +54,8 @@ namespace AttributeWithTypeArgument @@ -54,8 +54,8 @@ namespace AttributeWithTypeArgument
{
}
}
//$$ AttributeAppliedToEvent (ignored)
namespace AttributeAppliedToEvent
//$$ AppliedToEvent
namespace AppliedToEvent
{
[AttributeUsage(AttributeTargets.Event)]
public class MyAttributeAttribute : Attribute
@ -67,8 +67,8 @@ namespace AttributeAppliedToEvent @@ -67,8 +67,8 @@ namespace AttributeAppliedToEvent
public event EventHandler MyEvent;
}
}
//$$ AttributeAppliedToField
namespace AttributeAppliedToField
//$$ AppliedToField
namespace AppliedToField
{
[AttributeUsage(AttributeTargets.Field)]
public class MyAttributeAttribute : Attribute
@ -80,8 +80,8 @@ namespace AttributeAppliedToField @@ -80,8 +80,8 @@ namespace AttributeAppliedToField
public int Field;
}
}
//$$ AttributeAppliedToProperty
namespace AttributeAppliedToProperty
//$$ AppliedToProperty
namespace AppliedToProperty
{
public class TestClass
{
@ -95,11 +95,11 @@ namespace AttributeAppliedToProperty @@ -95,11 +95,11 @@ namespace AttributeAppliedToProperty
}
}
}
//$$ AttributeAppliedToDelegate
//$$ AppliedToDelegate
[Obsolete("reason")]
public delegate int AttributeAppliedToDelegate();
//$$ AttributeAppliedToMethod
namespace AttributeAppliedToMethod
public delegate int AppliedToDelegate();
//$$ AppliedToMethod
namespace AppliedToMethod
{
[AttributeUsage(AttributeTargets.Method)]
public class MyAttributeAttribute : Attribute
@ -113,27 +113,41 @@ namespace AttributeAppliedToMethod @@ -113,27 +113,41 @@ namespace AttributeAppliedToMethod
}
}
}
//$$ AttributeAppliedToInterface
//$$ AppliedToInterface
[Obsolete("reason")]
public interface AttributeAppliedToInterface
public interface AppliedToInterface
{
}
//$$ AttributeAppliedToStruct
//$$ AppliedToStruct
[Obsolete("reason")]
public struct AttributeAppliedToStruct
public struct AppliedToStruct
{
public int Field;
}
//$$ NamedPropertyParameter
namespace NamedPropertyParameter
//$$ AppliedToParameter
namespace AppliedToParameter
{
[AttributeUsage(AttributeTargets.Parameter)]
public class MyAttributeAttribute : Attribute
{
}
public class MyClass
{
public void Method([MyAttribute]int val)
{
}
}
}
//$$ NamedInitializerProperty
namespace NamedInitializerProperty
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class MyAttributeAttribute : Attribute
{
}
}
//$$ NamedStringPropertyParameter
namespace NamedStringPropertyParameter
//$$ NamedInitializerPropertyString
namespace NamedInitializerPropertyString
{
[AttributeUsage(AttributeTargets.All)]
public class MyAttributeAttribute : Attribute
@ -155,8 +169,8 @@ namespace NamedStringPropertyParameter @@ -155,8 +169,8 @@ namespace NamedStringPropertyParameter
{
}
}
//$$ NamedTypePropertyParameter
namespace NamedTypePropertyParameter
//$$ NamedInitializerPropertyType
namespace NamedInitializerPropertyType
{
[AttributeUsage(AttributeTargets.All)]
public class MyAttributeAttribute : Attribute
@ -178,8 +192,8 @@ namespace NamedTypePropertyParameter @@ -178,8 +192,8 @@ namespace NamedTypePropertyParameter
{
}
}
//$$ NamedEnumPropertyParameter
namespace NamedEnumPropertyParameter
//$$ NamedInitializerPropertyEnum
namespace NamedInitializerPropertyEnum
{
[AttributeUsage(AttributeTargets.All)]
public class MyAttributeAttribute : Attribute
@ -201,8 +215,8 @@ namespace NamedEnumPropertyParameter @@ -201,8 +215,8 @@ namespace NamedEnumPropertyParameter
{
}
}
//$$ NamedEnumFieldParameter
namespace NamedEnumFieldParameter
//$$ NamedInitializerFieldEnum
namespace NamedInitializerFieldEnum
{
[AttributeUsage(AttributeTargets.All)]
public class MyAttributeAttribute : Attribute

2
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs

@ -38,7 +38,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -38,7 +38,7 @@ namespace ICSharpCode.NRefactory.CSharp
This
}
public class ParameterDeclaration : AstNode
public class ParameterDeclaration : AttributedNode
{
public static readonly Role<AttributeSection> AttributeRole = AttributedNode.AttributeRole;
public static readonly Role<CSharpTokenNode> ModifierRole = new Role<CSharpTokenNode>("Modifier", CSharpTokenNode.Null);

3
NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs

@ -1110,7 +1110,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1110,7 +1110,8 @@ namespace ICSharpCode.NRefactory.CSharp
}
WriteCommaSeparatedList(attributeSection.Attributes);
WriteToken("]", AstNode.Roles.RBracket);
NewLine();
if (!(attributeSection.Parent is ParameterDeclaration))
NewLine();
return EndNode(attributeSection);
}

Loading…
Cancel
Save