Skip to content

Commit

Permalink
Annotate anonymous methods/lambdas with the MethodDefinition represen…
Browse files Browse the repository at this point in the history
…ting the lambda body.
  • Loading branch information
dgrunwald committed May 27, 2011
1 parent c2eb917 commit e8b6e3d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ICSharpCode.Decompiler/Ast/Transforms/DelegateConstruction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ bool HandleAnonymousMethod(ObjectCreateExpression objectCreateExpression, Expres

// Create AnonymousMethodExpression and prepare parameters
AnonymousMethodExpression ame = new AnonymousMethodExpression();
ame.CopyAnnotationsFrom(objectCreateExpression); // copy ILRanges etc.
ame.RemoveAnnotations<MethodReference>(); // remove reference to delegate ctor
ame.AddAnnotation(method); // add reference to anonymous method
ame.Parameters.AddRange(AstBuilder.MakeParameters(method, isLambda: true));
ame.HasParameterList = true;

Expand Down Expand Up @@ -180,6 +183,7 @@ from ident in body.Descendants.OfType<IdentifierExpression>()
}
if (isLambda) {
LambdaExpression lambda = new LambdaExpression();
lambda.CopyAnnotationsFrom(ame);
ame.Parameters.MoveTo(lambda.Parameters);
Expression returnExpr = ((ReturnStatement)body.Statements.Single()).Expression;
returnExpr.Remove();
Expand Down

0 comments on commit e8b6e3d

Please sign in to comment.