As you all know, ReSharper has lots of inspections, all of varying complexity. Some inspections present a multitude of choices – for example, when ReSharper meets an undeclared symbol, it has no idea what to make of it. Does the user want it as a parameter, a local variable or perhaps a field or property of the containing class?
On the other hand, plenty of fixes are unambiguous. Some examples include:
this.prefix on class members
Properties with backing fields that can be transformed into auto-properties
There are two ways that users can interact with these inspections. The first, and most direct, way is via a quick-fix — that little pop-up that shows up in code when the cursor is at a location where a fix can be applied:
Another option is to invoke a predefined set of fixes in bulk at the scope of a file, folder, project or solution. This is the Code Cleanup mechanism that can fix a configurable set of issues in every file in the selected scope:
However, in ReSharper 8 we’re introducing a new mechanism that we call Fix in Scope. This feature is an extension of the quick-fix mechanic that lets you either apply the fix just in a particular location or, alternatively, you can expand the menu and pick a wider scope for the fix to be applied:
Here’s a video overview of Fix in Scope — one of several videos about ReSharper 8 available on YouTube:
It is our hope that this feature helps you streamline fixes of a particular type when you need to do them en masse. For example, you’re starting a new project, and a default project template generates lots of plumbing with lots of unnecessary
using statements. Just move the cursor over one of the unused directives, expand the Remove unused directives in file, pick Remove unused directives in project and you’re done — extraneous using statements in all files in the project will be instantly removed!
At the moment, Fix In Scope supports a set of features provided by Code Cleanup. Here’s a (hopefully) complete list:
In the future, we plan to expand the set of supported inspections to make the process of code improvement even more streamlined. Meanwhile, we suggest you check out ReSharper 8 and let us know what you think!