diff --git a/src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs index 5aa3a6bf0c..bccd95799e 100644 --- a/src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs @@ -1613,7 +1613,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter PrintIndentedBlock(doLoopStatement.EmbeddedStatement); outputFormatter.Indent(); - outputFormatter.PrintToken(Tokens.Loop); + if (doLoopStatement.ConditionPosition == ConditionPosition.Start && doLoopStatement.ConditionType == ConditionType.While) { + outputFormatter.PrintToken(Tokens.End); + outputFormatter.Space(); + outputFormatter.PrintToken(Tokens.While); + } else { + outputFormatter.PrintToken(Tokens.Loop); + } if (doLoopStatement.ConditionPosition == ConditionPosition.End && !doLoopStatement.Condition.IsNull) { outputFormatter.Space(); diff --git a/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs b/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs index ecd4cdc786..017adf5410 100644 --- a/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs +++ b/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBConverterTest.cs @@ -336,5 +336,14 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter TestStatement("c = a ?? b;", "c = IIf(a Is Nothing, b, a)"); } + + [Test] + public void ConvertedLoop() + { + TestStatement("while (cond) example();", + "While cond\n" + + "\texample()\n" + + "End While"); + } } }