"Value assigned is not used in any execution path" is incorrectly reported for a For/Next loop index

Resharper is reporting "Value assigned is not used in any execution path" for the index variable of a VB For/Next loop. For instance, it will give the warning for i in the code snippet below.

    Public Sub Foo(bar As Action, n As Integer)
      For i As Integer = 0 To n - 1
        bar.Invoke()
      Next
    End Sub


The warning is inappropriate because the value is used -- it is used to evaluate the looping condition.

I found a post reporting this issue back in 2011 (http://devnet.jetbrains.com/message/5310330), but there seems to have been no follow-up.

-TC

0

Please sign in to leave a comment.