Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-277144: Introduce Variable breaks my code (VB)

$
0
0
Reporter Egor Malyshev (megor) Egor Malyshev (megor)
Created Oct 14, 2011 5:18:09 PM
Updated Apr 20, 2018 6:13:59 PM
Resolved Apr 20, 2018 6:13:59 PM
Subsystem Refactorings
Assignee Alisa Afonina (alisa.afonina)
Priority Critical
State Obsolete
Type Bug
Fix version Backlog
Affected versions No Affected versions
Fixed In Version ReSharper Undefined
VsVersion All Versions
I have this code:

If Not ProjectItem.ContainsWords(CType(ti.Tag, ProjectItem).NameFormatted, Format("{0} {1}", CType(ti.Tag, ProjectItem).DisplayName, finderCombo.Text)) Then
speedFinder.Items.Remove(CType(ti.Tag, ProjectItem).AsDropDownItem)
End If

Note that there is a call to shared ContainsWords from ProjectItem class. Now, I see that this part CType(ti.Tag, ProjectItem) is used 3 times a row, so it's wise to extract a variable, which is what I do, but here's a bummer:

Dim projectItem As ProjectItem = CType(ti.Tag, ProjectItem)
If Not projectItem.ContainsWords(projectItem.NameFormatted, Format("{0} {1}", projectItem.DisplayName, finderCombo.Text)) Then
speedFinder.Items.Remove(projectItem.AsDropDownItem)
End If

R# has introduced variable with name projectItem, which has replaced ProjectItem in call to shared sub, and now I have to correct it manually, because even if I use Rename on variable, it will replace projectItem before ContainsWords too, which would still render my code broken.

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>