Browse Source

Fixed decompilation of automatic event that has attributes on the accessors.

pull/348/merge
Daniel Grunwald 13 years ago
parent
commit
82154e1eb6
  1. 5
      ICSharpCode.Decompiler/Ast/Transforms/PatternStatementTransform.cs
  2. 13
      ICSharpCode.Decompiler/Tests/CustomAttributes/S_CustomAttributeSamples.cs

5
ICSharpCode.Decompiler/Ast/Transforms/PatternStatementTransform.cs

@ -897,6 +897,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -897,6 +897,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
#region Automatic Events
static readonly Accessor automaticEventPatternV4 = new Accessor {
Attributes = { new Repeat(new AnyNode()) },
Body = new BlockStatement {
new VariableDeclarationStatement { Type = new AnyNode("type"), Variables = { new AnyNode() } },
new VariableDeclarationStatement { Type = new Backreference("type"), Variables = { new AnyNode() } },
@ -965,6 +966,10 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -965,6 +966,10 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
return null;
EventDeclaration ed = new EventDeclaration();
ev.Attributes.MoveTo(ed.Attributes);
foreach (var attr in ev.AddAccessor.Attributes) {
attr.AttributeTarget = "method";
ed.Attributes.Add(attr.Detach());
}
ed.ReturnType = ev.ReturnType.Detach();
ed.Modifiers = ev.Modifiers;
ed.Variables.Add(new VariableInitializer(ev.Name));

13
ICSharpCode.Decompiler/Tests/CustomAttributes/S_CustomAttributeSamples.cs

@ -69,6 +69,19 @@ namespace AppliedToEvent @@ -69,6 +69,19 @@ namespace AppliedToEvent
public event EventHandler MyEvent;
}
}
//$$ AppliedToEventMethods
namespace AppliedToEventMethods
{
[AttributeUsage(AttributeTargets.Method)]
public class MyAttributeAttribute : Attribute
{
}
public class TestClass
{
[method: MyAttribute]
public event EventHandler MyEvent;
}
}
//$$ AppliedToField
namespace AppliedToField
{

Loading…
Cancel
Save