JetBrains Rider 2026.1 Help

Code inspection: Convert 'if do while' into 'while'

This inspection reports an if statement that only guards a do ... while loop with the same condition.

That pattern is equivalent to a while loop and is usually harder to read because the same condition is written twice.

Example

while (true) { if (count > 0) { do { count--; } while (count > 0); } }
while (true) { while (count > 0) { count--; } }

Quick-fix

The quick-fix converts the if + do ... while construct into a single while loop.

27 March 2026