Turning bugs into features
I’m using R# for over a decade now, and it has gotten to the point where I’m actually able to utilize R# bugs to get things working better for me.
In this case, the scenario is using the Find Usages as a refactoring aid. I have a tricky refactoring to do, which require me to touch several pieces of code. In order to handle this properly, I start by Finding Usages on the relevant item. In this case, ByView.
Then I go to each of those code locations and make the require modifications.
So far, so good, but on complex scenarios, it is hard to remember which portions I have done and which portions are still left undone. In order to handle this, I Ctrl+X, Ctrl+Z the line I find. R# detect this as a change to the code that invalidate the found usage, and suddenly, I got a nice todo list with a strikethrough for completed tasks.
Comments
Nice trick, I'll keep it in mind!
Nice "feature" I'm wondering if the R# guys would like to incorporate this as a real feature, it seems to me that this can be really useful. the functionality could be something in the lines of: 1- Mark portions of code to be changed. 2- R# keeps a list of this portions of code and it would generate a TODO list. 3- As an additional feature on top of that it could be useful to get diffs between the old portion and the new one.
Isn't the point of R# that it should be able to make whatever change you want to make for you so you don't have to go through each usage manually?
Of course, you could just use the actual feature for keeping track of where you are - right click on an item in the results list and click "ignore". I think you can hit the Del key to make it easier. It even supports multi-select.
Neil, In this case, it isn't something that it supports. I changed the return value of a method to be disposable, and needed to go and add using statements and some handling to all the call sites
Matthew, That doesn't give me the strike through, and require me to actual think. I discovered this by accident, then started using this a lot because it works very well with my style of work
What I would do in that case is change the method name without using R# to GetIndexDisposable(). Then write a new method GetIndex() with the same signature which calls GetIndexDisposable() inside a using statement and does whatever else you want to do. Then using R# Inline Method on GetIndex() and R# Rename GetIndexDisposable() back to GetIndex()
I was using this 'feature' exactly for the same reason as you are :)
Why you think this is a "bug"? This is a feature and its works as intended.
It's really hard to track changes in code, especially keep track of semantic information. ReSharper do it's best to handle textual changes and keep track of particular syntax nodes (including changes outside and inside of this syntax node). Tracking semantic references (the fact that member usage is still points to the same member) is harder, but still possible and R# does this when possible. When R# losts the track of particular refactored member usage - you get nice strike through presentation.
So what is a "bug" here?
Alexander, I consider this a bug because I did Ctrl+X, Ctrl+Z (cancelling the previous edit operation). The code didn't change.
Comment preview