Browse Source

Display return type attributes on delegates.

pull/150/head
Daniel Grunwald 14 years ago
parent
commit
576a13214c
  1. 12
      ICSharpCode.Decompiler/Ast/AstBuilder.cs
  2. 10
      ICSharpCode.Decompiler/Tests/CustomAttributes/S_CustomAttributeSamples.cs

12
ICSharpCode.Decompiler/Ast/AstBuilder.cs

@ -259,6 +259,7 @@ namespace ICSharpCode.Decompiler.Ast
if (m.Name == "Invoke") { if (m.Name == "Invoke") {
dd.ReturnType = ConvertType(m.ReturnType, m.MethodReturnType); dd.ReturnType = ConvertType(m.ReturnType, m.MethodReturnType);
dd.Parameters.AddRange(MakeParameters(m)); dd.Parameters.AddRange(MakeParameters(m));
ConvertAttributes(dd, m.MethodReturnType, m.Module);
} }
} }
result = dd; result = dd;
@ -1065,9 +1066,14 @@ namespace ICSharpCode.Decompiler.Ast
} }
#endregion #endregion
ConvertCustomAttributes(attributedNode, methodDefinition.MethodReturnType, "return"); ConvertAttributes(attributedNode, methodDefinition.MethodReturnType, methodDefinition.Module);
if (methodDefinition.MethodReturnType.HasMarshalInfo) { }
var marshalInfo = ConvertMarshalInfo(methodDefinition.MethodReturnType, methodDefinition.Module);
void ConvertAttributes(AttributedNode attributedNode, MethodReturnType methodReturnType, ModuleDefinition module)
{
ConvertCustomAttributes(attributedNode, methodReturnType, "return");
if (methodReturnType.HasMarshalInfo) {
var marshalInfo = ConvertMarshalInfo(methodReturnType, module);
attributedNode.Attributes.Add(new AttributeSection(marshalInfo) { AttributeTarget = "return" }); attributedNode.Attributes.Add(new AttributeSection(marshalInfo) { AttributeTarget = "return" });
} }
} }

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

@ -468,3 +468,13 @@ namespace ClassAttributeOnTypeParameter
{ {
} }
} }
//$$ AttributeOnReturnTypeOfDelegate
namespace AttributeOnReturnTypeOfDelegate
{
[AttributeUsage(AttributeTargets.All)]
public class MyAttributeAttribute : Attribute
{
}
[return: MyAttribute]
public delegate void Test();
}

Loading…
Cancel
Save