Is there a shortcut for Resharper to allow it to execute all green and yellow suggestions?
I have some code where there are a series of "green" light bulb suggestions that Resharper is telling me I could use an object initializer for.
I see this kind of thing in legacy code all the time, where there's some code pattern repeated over and over again where Resharper knows how to clean it up automatically for me, but I have to go to each item and use a shortcut key on each item to execute the refactoring.
What I want to know: Is there a way (shortcut/whatever) t开发者_JS百科o tell Resharper that I want it to go ahead and execute all of these "light bulb" refactorings, or at least all the ones where there's only one suggestion. I can understand if there are two suggestions it would know which one to use.
Currently there's no way to auto-apply quick-fixes. There was a similar question recently with answers providing a bit more details.
One thing that I'd suggest right now is to use Find similar issues introduced in ReSharper 6: this will at least make sure that you can access all code positions where ReSharper highlights this particular inspection, and apply the quick-fix with a tedious repeat of Enter (open the file with the detected issue and select the highlighted piece of code) - Esc (navigate from "Inspection Results" tool window to the code editor) - Alt+Enter (open the quick-fix menu) - Enter (apply the quick-fix) - Alt+R,W,I (return to Inspection Results)
There's silent clean-up which can be mapped to a config profile. This will action all of of the preferences defined in the profile on ctrl-e,f
(VS scheme).
By default I don't think it has a profile assigned so you have to set one first in the options. Also the shortcut varies depending on whether you have VS shortcuts or R shortcuts.
精彩评论