Fix in Scope: a New Code Cleanup Experience in ReSharper 8
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!
Subscribe to Blog updates
Creating Custom AI Prompts
AI has swept through the software development industry like a wildfire. So people want to learn how to best use AI in their day to day tasks. In this post we’ll take a look at how to write custom prompts for use with the JetBrains AI Assistant in ReSharper and Rider so you can make the most of AI.&n…
12 Debugging Techniques In JetBrains Rider You Should Know About
Twelve must know debugging features in JetBrains Rider every developer should know.
Interceptors – Using C# 12 in Rider and ReSharper
Welcome to our series, where we take a closer look at the C# 12 language features and how ReSharper and Rider make it easy for you to adopt them in your codebase. If you haven’t yet, download the latest .NET 8 SDK and update your project files! In this series, we are looking at: Primary …