ReSharper 2017.1 Help

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

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:

  1. Status indicator that helps you to see at once whether the current file has errors or warnings.
  2. 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.
  3. A low-priority code issue (in this case, a suggestion related to an unused public member) is greyed out.
  4. 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.
  5. A marker corresponding to the suggestion issue (3) is displayed on the marker bar.
  6. A marker corresponding to the error issue (8) is displayed on the marker bar.
  7. An action indicator that appears to the left of the caret position if ReSharper has anything to suggest there.
  8. 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.
  9. A marker corresponding to the warning issue (4) is displayed on the marker bar.
  10. 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.
  11. A short description of the issue at the caret appears in the status bar. You can also view descriptions of code issues by hovering the mouse over highlighted code or over the issue markers on the marker bar (5,6,9)
  12. 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

  1. On the Code Inspection | Settings page of ReSharper options, 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.
  2. If necessary, you can select the Analyze errors in whole solution check box to enable the Solution-Wide Analysis.
  3. 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.

Navigating between code issues

If the design-time code inspection is enabled, you can easily navigate between issues detected in your code.

To navigate to the next/previous code issue in the current file

  • Press F12 to go to the next code issue, or Shift+F12 to go to the previous code issue.
  • In the main menu, choose ReSharper | Inspect | Next Issue in File or ReSharper | Inspect | Previous Issue in File .
  • Use the marker bar on the right side of the editor window: clicking on markers brings the caret to the corresponding issues; clicking on the status indicator on top of the marker bar brings the caret to the next issue in the file.
  • Right-click on the status indicator and choose Go to Next/Previous Error/Warning/Suggestion - these commands will help you navigate between issues of the highest severity level. So if there are errors, they only navigate between errors, as soon as all errors are fixed they navigate between warnings, and so on.

If you are only interested in errors in the current file, you can jump between them skipping issues with lower severity levels. Besides, if you enable the Solution-Wide Analysis, you can jump between errors in the entire solution. Note that names of the navigation commands in the ReSharper | Inspect menu change if the solution-wide analysis is on. Specifically, Next Error/Warning changes to Next Error/Warning in Solution and Previous Error/Warning becomes Previous Error/Warning in Solution.

To navigate to the next/previous error

  • Press Alt+F12 to go to the next error, or Shift+Alt+F12 to go to the previous error.
  • In the main menu, choose ReSharper | Inspect | Next Error/Warning or ReSharper | Inspect | Previous Error/Warning .
  • If the Solution-Wide Analysis is enabled and there are some errors, the number of error is displayed in the right corner of the status bar. You can click this number to go to the next error in the solution.

Inspection options menu

Besides suggested fixes, for each configurable code inspection as well as for custom inspections, ReSharper shows the Inspection [name of inspection] /help/img/dotnet/2017.1/ThemedIcon.Settings.Screen.[Gray].png sub-menu in the actions list, with the following items:

Inspection [name of inspection] sub-menu

You can disable the 'Inspection options' sub-menu. To do so, clear the Show code inspection options in action list check box on the Code Inspection | Settings page of ReSharper options.

Finding similar issues

You can not only fix a highlighted issue with a quick-fix, but also find and investigate all similar issues (all issues detected with the same code inspection) in the whole solution or smaller scope.

To find similar issues

  1. Set the caret at a highlighted issue in the editor.
  2. Press Alt+Enter or click on the action indicator to the left of the caret to open the action list.
  3. To find similar issues in the current file, choose Inspection [name of inspection] | Find similar issues in [file name] file.
  4. To find similar issues in the current project or solution, expand the submenu and choose the desired scope:
    Using action list to find similar issues
  5. If necessary, you can search for similar issues in any project or solution folder within your solution. To do so, choose Find similar issues in custom scope in the submenu.
    In the dialog that opens, type the name of the desired project or solution folder, and then click OK.
    Specifying search scope for the similar issues
  6. All found issues will be displayed in the Inspection Results window.

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 quick-fixes. 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 using directives:

Two light bulbs for fixing the same issue

To avoid this, ReSharper provides the Do not show Visual Studio bulb... option on the Code Inspection | Settings page of ReSharper options. 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, the Visual Studio's action becomes available in the ReSharper's action list. You can recognize Visual Studio's quick actions by the special icon /help/img/dotnet/2017.1/ThemedIcon.YellowBulbVS.Screen.[Gray].png.

If necessary, you can also disable Visual Studio's error highlighting in the editor, so that only code issues found by ReSharper are highlighted. To do so, select Suppress Visual Studio squiggles... on the Code Inspection | Settings page of ReSharper options.

See Also

Last modified: 31 May 2017