When you see a piece of code that is highlighted as error, warning, suggestion, or hint it means that the ReSharper's Code Analysis is enabled. In most cases, these code issues can be repaired or improved instantly using quick-fixes.
Quick-fixes are represented by a red or yellow light bulb icon that appears automatically to the left of a highlighted code line, when you position the caret on the highlight:
- Yellow light bulb represents a quick-fix for code issues with warning, suggestion or hint severity
- Red light bulb represents a quick-fix for for code issues with error severity
Some quick-fixes act as shortcuts to ReSharper code generation features. They are identified with the following icon: . Also, there are quick-fixes associated with refactorings they are identified with the following icon: .
You can display the list of available quick-fixes for a given highlight, either by clicking the light bulb or by pressing Alt+Enter. Then simply select an appropriate quick-fix from the list, and it will correct your code automatically.
- Click a highlight (error, warning, suggestion, or hint) in the source code, or the corresponding marker in the Marker Bar to show the light bulb.
- Click the red or yellow bulb, or press Alt+Enter.
- Select the desired quick-fix in the drop-down list of available actions, or select the action using arrow keys and press Enter.
In some cases a quick-fix is applied and the code is updated
immediately. If a quick-fix involves direct editing of source code
(for example, Change All), the editor turns into special
mode, which is indicated by a blue highlight in red frame, and a
suggestion list is displayed:
- Select the desired option from the suggestion list and press Enter (to discard changes, press Esc). So doing, ReSharper detects all occurrences of the symbol that are highlighted as errors, and replaces them automatically.
The list of predefined quick-fixes can be extended with custom code inspections defined in the structural search and replace patterns. For more information, see Structural Search and Replace.
See Examples of Quick-Fixes for more practical examples of quick-fixes.
For guidelines on how to change inspection severity for issues that specific quick-fixes are designed to fix, see Configuring Warnings.