diff --git a/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs b/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs index e3751cace7..5da8dcf908 100644 --- a/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs @@ -598,6 +598,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 {