"Remove redundant variable" deletes method calls
Hello. I'd like to suggest a fix for the "Remove redundant variable" feature. Let's say we have the following: a method return value is assigned to an unused variable, i.e.:
object unusedVariable = MyMethod();
// "unusedVariable" not used anywhere below
Hence ReSharper will mark "unusedVariable" with a warning and if the user tries to remove it using the "Remove redundant variable" item from the R# menu (under the light bulb), the variable will be deleted along with the method call. However, this call may be needed regardless of the variable usage and so the functionality could be damaged. I think in such cases it'd be better if R# removes only the variable itself, not any method calls used in its assignment.
Best regards.
Please sign in to leave a comment.
Dimitar Dobrev wrote:
Thats true for me too. I walk along our code, to optimize code, using
this bulbs to remove unused variables. And when i run app, then it stop
working. I will discover that it removes some method calls, and it
breaks our logic.
+1 for this fix.
--
Peter Sulek
terrorix@centrum.sk
XanaNews ver. 1.18.1.6
+1
This bug is related to this issue, which JetBrains won't fix
http://www.jetbrains.net/jira/browse/RSRP-36922
+1 from me