Detecting Code Issues in Design Time
ReSharper starts analyzing a code file as soon as you open it in the editor, all the way you edit it, until it is closed. All detected code issues are highlighted in the editor according to their severity levels. The map of the issues is also displayed on the marker bar in the right part of the editor window, where you can see instantly the status of the file and click the marks to navigate to specific code issues.
In this topic:
- Design-time inspection features
- Toggling design-time inspection
- Inspection options menu
- Integration with Visual Studio code inspection controls
Design-time inspection features
To illustrate the design-time code inspection performed by ReSharper, consider the following code excerpt displayed in the Visual Studio editor:
In this rather simple example, we can see the following features of ReSharper code inspection:
- Status indicator that helps you to see at once whether the current file has errors or warnings.
- A fix pop-up that appears for non-imported types. It is enough to press Alt+Enter or click on this pop-up and ReSharper will add the missing directive for all types in the file. For more information, see Importing Missing Namespaces.
- A low-priority code issue (in this case, a suggestion related to an unused public member) is highlighted with a greyed out text.
- A medium-priority code issue (in this case, a warning about a symbol name that does not fit with the naming style) is highlighted with a blue curly underline.
- A mark corresponding to the suggestion issue (3) is displayed on the marker bar.
- A mark corresponding to the error issue (8) is displayed on the marker bar.
- An action indicator that appears to the left of the caret position if ReSharper has anything to suggest there.
- A high-priority code issues (in this case, errors related to an unresolved symbol and an incorrect return type) are highlighted with red text and red curly underline.
- A mark corresponding to the warning issue (4) is displayed on the marker bar.
- The action list, which opens by pressing Alt+Enter or clicking the action indicator (7), contains a list of quick-fixes for the issue at the caret.
- A short description of the issue at the caret appears in the status bar. For more information, see Finding Out What is Wrong with Your Code.
- If the solution-wide analysis is enabled, ReSharper allows you to see even more code issues. In this example, it detects the unused public member (3) and notifies about errors in other files of your solution. You can click on the solution-wide analysis icon to explore the detected issues.
Toggling design-time inspection
By default, design-time code inspection is enabled in all supported languages. However, you can disable it everywhere or turn it off for specific files if needed. For more information on configuring code inspection, see Configuring Code Inspection Settings.
To disable or enable design-time code inspection
- In the Code Inspection | Settings options page, use the Enable code analysis check box to toggle the design-time code inspection. While you are on this page, you can check out which options you can configure for the code inspection.
- If necessary, you can select the Analyze errors in whole solution check box to enable the Solution-Wide Analysis.
- Click Save to apply the modifications and let ReSharper choose where to save them, or save the modifications to a specific settings layer using the Save To drop-down list. For more information, see Managing and Sharing ReSharper Settings.
Inspection options menu
- Disable once with comment
- Disable and restore with comment
- Configure inspection severity
- Find all issues of this type
- For the most controversial issues, there is the Why is ReSharper suggesting this? item that opens a code inspections reference page with detailed description of the corresponding inspection.
You can disable the 'Inspection options' sub-menu. To do so, uncheck the Show code inspection options in action list check-box in the Code Inspection | Settings options page.
Integration with Visual Studio code inspection controls
Starting from version 2015, Visual Studio comes with its own code analysis engine (Roslyn) and provides its own 'light bulbs' feature to perform quick actions including refactoring and fixing errors.
Visual Studio's quick actions often perform the same fixes as ReSharper's
Therefore, for some errors you may have two similar error-fixing suggestions from Visual Studio and from
ReSharper. In the illustration below, you can see two bulbs both suggesting to remove redundant
To avoid this, ReSharper provides the Do not show Visual Studio bulb... option on the Code Inspection | Settings page. This option is enabled by default, so you will not see the duplicated bulbs unless you disable it.
Although ReSharper by default suppresses Visual Studio bulbs, it does not simply disable Visual Studio quick actions. For each Visual Studio's quick action, ReSharper does the following:
- If there is a similar ReSharper's quick-fix, the Visual Studio's quick action is not displayed
- If there are no similar ReSharper's quick-fixes, Visual Studio's action becomes available in the ReSharper's action list. You can recognize Visual Studio's quick actions by the special icon .
If necessary, you can also disable Visual Studio's error highlighting in the editor, so that only ReSharper's highlighting appears. To do so, select Suppress Visual Studio squiggles... on the Code Inspection | Settings and restart Visual Studio.