Thanks for the wonderful tool. Here is an improvement that would make code conversion much easier.
When converting For loops from VB.NET to C#, if the final value of the range is not constant, a loopTo variable is added. While it makes sense from a semantic point of view, this makes the code slightly less readable.
If there are multiple for loops, we end up with a series of loopTo, loopTo2, loopTo3 etc. It would be wonderful if this could be simplified if possible.
For example, the following VB.NET code:
For i As Integer = 1 To n
Next
Is translated as:
for (int i = 1, loopTo = n; i <= loopTo; i++) { }
Proposed solution
When the upper bound is a local variable that is not explicited modified or passed as reference in the loop, simply use that variable instead of creating a duplicate. In the previous example, this would be:
for (int i = 1; i <= n; i++) { }
Another handy improvement would be when iterating from 0 to n - 1 when the loop variable is an integer.
For i As Integer = 0 To n - 1
Next
Would be translated using a strict comparison:
for (int i = 0; i < n; i++) { }
Thanks for the wonderful tool. Here is an improvement that would make code conversion much easier.
When converting
Forloops from VB.NET to C#, if the final value of the range is not constant, aloopTovariable is added. While it makes sense from a semantic point of view, this makes the code slightly less readable.If there are multiple for loops, we end up with a series of
loopTo,loopTo2,loopTo3etc. It would be wonderful if this could be simplified if possible.For example, the following VB.NET code:
Is translated as:
Proposed solution
When the upper bound is a local variable that is not explicited modified or passed as reference in the loop, simply use that variable instead of creating a duplicate. In the previous example, this would be:
Another handy improvement would be when iterating from
0ton - 1when the loop variable is an integer.Would be translated using a strict comparison: