IDE0059 - Remove redundant assignment triggered for variable used from closure #32946
Labels
4 - In Review
A fix for the issue is submitted for review.
Area-IDE
Bug
IDE-CodeStyle
Built-in analyzers, fixes, and refactorings
Milestone
Version Used: VS 16.0 Preview 2.0
Steps to Reproduce:
Expected Behavior:
IDE0059 is not fired, and no suggested fix to remove a redundant assignment is made.
Actual Behavior:
IDE0059 fires and suggests to remove the redundant assignment, which results in:
which doesn't compile. Adding a use site outside the lambda/delegate body makes IDE0059 go away.
Context:
The bigger repro for this issue is a place where we cache delegates that have a reference to a loop variable, which is copied to a local inside the body of a
for
loop, like this:The text was updated successfully, but these errors were encountered: