ReSharper 2016.2 Help

Fix in Scope

Most of quick-fixes can fix the current issue under the caret, but some of them (e.g. Remove unused directives, Make field read-only, Remove redundant cast, etc.) can also automatically find and fix issues in a larger scope - in the current file, in the current project or in the whole solution.

In this topic:

Applying fix in scope

You can recognize such fix by a small arrow displayed next to it in the action list.

Scalable quick-fix

To apply fix in scope

  1. Set the caret to a code issue highlighted by a ReSharper's inspection.
  2. Press Alt+Enter or click on the action indicator to the left of the caret to open the action list.
  3. Choose a quick fix that you want to apply.
  4. Click on the arrow to right of the quick-fix or press the right arrow key to expand the list of available scopes. If there is no arrow to the right of a quick-fix, then this quick-fix only applies locally.
  5. Select the scope for the quick-fix to apply and click on it or press Enter.

All files where ReSharper applies fix in scope open in editor tabs. If necessary, you can undo all that was changed in these files with a single command: choose Edit | Undo in the main menu or press Ctrl+Z.

Fixing inconsistent naming in scope

The quick-fix that fixes inconsistent naming, calls the Rename Refactoring to make sure that all occurrences of the symbol are renamed in your solution.

Quick-fix for naming style violation

Therefore, when you choose to fix naming in a wider scope, ReSharper displays an additional dialog where you can select items to rename:

Fix in scope: bulk rename

The list of quick-fixes that can be applied in wider scope

The full list of quick-fixes that can be applied in wider scopes includes:

C++

  • Replace expression with 'false'
  • Fix slashes in import file path
  • Add 'override' specifier to an overriding function
  • Replace expression with 'nullptr'
  • Remove redundant qualifier

Common

  • Use string interpolation
  • Pass string interpolation
  • Rename to ''
  • Move to '' namespace
  • Make fields readonly (see Making Fields Readonly)

ASP.NET (C#)

ASP.NET (VB.NET)

  • Remove redundant 'imports' in file

ASP.NET

  • Optimize register directives

HTML

  • Add/change quotes

TypeScript

  • Fix relative path style
  • Specify '' explicitly
  • Convert cast to 'as' operator
  • Remove redundant qualifier
  • Remove redundant reference comment
  • Remove unused 'import' statement
  • Remove redundant type specification
  • Convert to ECMAScript 6 import statement
  • Change to ECMAScript 6 'export default'

JavaScript

  • Add explicit 'null'
  • Add missing comma
  • Convert to template string
  • Make all variables from this list block-scope
  • Move variable '' to inner block
  • Remove unexpected comma
  • Fix property name
  • Add/change quotes
  • Terminate all unterminated statements in file

C#

  • (see Value and Nullability Analysis)
  • To expression body
  • Clarify precedence with parentheses
  • Add missing/Remove redundant argument name (see Using Named/Positional Arguments)
  • Remove redundant 'internal' modifier (see Arranging Modifiers)
  • Place attributes into single section (see Attributes Style)
  • Add missing braces/Remove redundant braces (see Using Braces for Single Nested Statements)
  • Sort modifiers (see Arranging Modifiers)
  • Remove redundant parentheses (see Arranging Optional Parentheses)
  • Remove unnecessary whitespace
  • Separate statements with blank line
  • Remove argument name specification
  • Remove redundant verbatim prefix
  • Remove 'unchecked' expression
  • Remove semicolon
  • Unwrap from delegate creation
  • Replace with count access
  • Use 'nameof' expression
  • use type keyword/CLR type name (see Built-in Type References Style)
  • Use base class qualifier
  • Make auto-property get-only
  • Make auto-property get-only
  • Remove 'params' array creation
  • Remove property assignment
  • Remove redundant constructor
  • Remove redundant base constructor invocation
  • Make field read-only (see Making Fields Readonly)
  • Remove statement
  • Use array initializer
  • Remove redundant comma
  • Remove redundant 'string.Format()' call (see Code Analysis and Helpers for String Literals)
  • Convert to auto-property (see Using Auto-Properties)
  • Remove attribute
  • Use 'var' or explicit type depending on the code style settings.
  • Remove redundant argument(s) value
  • Remove initializer
  • Remove redundant parenthesis
  • Make operator 'public static'
  • (see Namespace Imports Assistance)
  • Import item and all other references (see Namespace Imports Assistance)
  • To extension method invocation
  • Remove 'new' modifier
  • Remove unused directives in file
  • Remove prohibited modifier(s)
  • Remove '()'
  • Remove as operator
  • Remove redundant comparison
  • Remove redundant constructor
  • Remove prohibited modifier(s)
  • Remove prohibited modifier(s)
  • Remove unused label
  • Remove 'partial' keyword
  • Remove prohibited modifier(s)
  • Remove redundant type specification
  • Remove redundant 'base()'
  • Remove redundant braces
  • Remove redundant delegate constructor call
  • Remove redundant else
  • Remove redundant name
  • Remove redundant 'new'
  • Remove redundant parenthesis
  • Remove redundant 'ToCharArray()'
  • Remove redundant condition
  • Remove redundant type arguments
  • Remove redundant 'int'
  • Replace 'unsafe' statement with its body
  • Remove 'sealed' keyword
  • Remove redundant signature
  • Remove prohibited modifier(s)
  • Remove redundant 'ToString' (see Code Analysis and Helpers for String Literals)
  • Remove prohibited modifier(s)
  • Remove 'unsafe' modifier

VB.NET

  • Make field read-only (see Making Fields Readonly)
  • Remove redundant 'imports' in file
  • Remove redundant qualifier
  • Remove 'ByVal' modifier
  • To implicitly typed

This feature is supported in the following languages/technologies:

C# VB.NET C++ HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts Protobuf JSON
Feature available Feature available Feature available Feature available Feature available Feature not available Feature available Feature available Feature not available Feature not available Feature not available Feature not available Feature not available Feature not available Feature not available

The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see corresponding topics in the ReSharper by Language section.

See Also

Last modified: 15 December 2016