diff --git a/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs b/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs index 076b2fcf13..52ffa500e4 100644 --- a/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs @@ -599,6 +599,7 @@ Statement TransformToForeach(UsingInstruction inst, Expression resource) // Add the variable annotation for highlighting (TokenTextWriter expects it directly on the ForeachStatement). foreachStmt.AddAnnotation(new ILVariableResolveResult(foreachVariable, foreachVariable.Type)); foreachStmt.AddAnnotation(new ForeachAnnotation(inst.ResourceExpression, conditionInst, singleGetter)); + foreachStmt.CopyAnnotationsFrom(whileLoop); // If there was an optional return statement, return it as well. if (optionalReturnAfterLoop != null) { return new BlockStatement {