Skip to content

Commit

Permalink
Fix #607: return value attributes missing in IL view
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrunwald committed Jul 12, 2015
1 parent 75dfa78 commit b018a18
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace ICSharpCode.Decompiler.Disassembler
/// </summary>
public sealed class ReflectionDisassembler
{
ITextOutput output;
readonly ITextOutput output;
CancellationToken cancellationToken;
bool isInType; // whether we are currently disassembling a whole type (-> defaultCollapsed for foldings)
MethodBodyDisassembler methodBodyDisassembler;
Expand Down Expand Up @@ -213,8 +213,9 @@ void DisassembleMethodInternal(MethodDefinition method)
output.WriteLine();
}
}
WriteParameterAttributes(0, method.MethodReturnType, method.MethodReturnType);
foreach (var p in method.Parameters) {
WriteParameterAttributes(p);
WriteParameterAttributes(p.Index + 1, p, p);
}
WriteSecurityDeclarations(method);

Expand Down Expand Up @@ -613,22 +614,17 @@ void WriteParameters(Collection<ParameterDefinition> parameters)
}
}

bool HasParameterAttributes(ParameterDefinition p)
void WriteParameterAttributes(int index, IConstantProvider cp, ICustomAttributeProvider cap)
{
return p.HasConstant || p.HasCustomAttributes;
}

void WriteParameterAttributes(ParameterDefinition p)
{
if (!HasParameterAttributes(p))
if (!cp.HasConstant && !cap.HasCustomAttributes)
return;
output.Write(".param [{0}]", p.Index + 1);
if (p.HasConstant) {
output.Write(".param [{0}]", index);
if (cp.HasConstant) {
output.Write(" = ");
WriteConstant(p.Constant);
WriteConstant(cp.Constant);
}
output.WriteLine();
WriteAttributes(p.CustomAttributes);
WriteAttributes(cap.CustomAttributes);
}

void WriteConstant(object constant)
Expand Down

0 comments on commit b018a18

Please sign in to comment.