Browse Source

Fix lambda expressions that are used within conditions.

pull/100/head
Daniel Grunwald 14 years ago
parent
commit
351808626e
  1. 6
      ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs

6
ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs

@ -222,11 +222,11 @@ namespace ICSharpCode.Decompiler.ILAst @@ -222,11 +222,11 @@ namespace ICSharpCode.Decompiler.ILAst
if (!Ast.Transforms.DelegateConstruction.IsAnonymousMethod(context, anonymousMethod))
return;
ILExpression expr = block.Body.ElementAtOrDefault(i + 1) as ILExpression;
if (expr != null && expr.GetSelfAndChildrenRecursive<ILExpression>().Count(
ILNode followingNode = block.Body.ElementAtOrDefault(i + 1);
if (followingNode != null && followingNode.GetSelfAndChildrenRecursive<ILExpression>().Count(
e => e.Code == ILCode.Ldsfld && ((FieldReference)e.Operand).ResolveWithinSameModule() == field) == 1)
{
foreach (ILExpression parent in expr.GetSelfAndChildrenRecursive<ILExpression>()) {
foreach (ILExpression parent in followingNode.GetSelfAndChildrenRecursive<ILExpression>()) {
for (int j = 0; j < parent.Arguments.Count; j++) {
if (parent.Arguments[j].Code == ILCode.Ldsfld && ((FieldReference)parent.Arguments[j].Operand).ResolveWithinSameModule() == field) {
parent.Arguments[j] = newObj;

Loading…
Cancel
Save