ReSharper 2016.1 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++

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

ASP.NET (C#)

ASP.NET (VB.NET)

  • Remove redundant 'imports'

ASP.NET

  • Optimize register directives

HTML

  • Add/change quotes everywhere

TypeScript

  • Fix 'public' modifier presence
  • Fix relative path style
  • Use 'any*' explicitly
  • Convert all casts to 'as' operators
  • Remove redundant qualifiers
  • Optimize reference comments
  • Optimize 'import' statements
  • Import all types
  • Typescriptify
  • Fix type explicitness
  • Fix type explicitness
  • Convert all obsolete constructs to ECMAScript 6
  • Convert all obsolete constructs to ECMAScript 6

JavaScript

  • Add explicit 'null'
  • Add missing comma
  • Convert to template string
  • Correct variable kinds
  • Fix all validation issues
  • Move all variables to narrower blocks
  • Remove unexpected comma
  • Fix JSON property names
  • Add/change quotes everywhere
  • Terminate all unterminated statements

C#

  • Annotate nullability (see Value and Nullability Analysis)
  • Use expression body for
  • Clarify precedence with parentheses
  • Add missing/Remove redundant argument name (see Using Named/Positional Arguments)
  • Remove redundant 'internal' modifiers (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 all redundant parentheses (see Arranging Optional Parentheses)
  • Cleanup whitespace
  • Separate control transfer statements
  • Remove redundant argument name specifications
  • Remove redundant verbatim prefixes
  • Remove redundant 'checked'/'unchecked' contexts
  • Remove semicolons
  • Unwrap immediate delegates
  • Use count access
  • Use 'nameof' expressions
  • Arrange qualifiers everywhere
  • Arrange qualifiers everywhere
  • everywhere use type keyword/CLR type name (see Built-in Type References Style)
  • Arrange qualifiers everywhere
  • Make properties get-only
  • Make properties get-only
  • Remove redundant parameter arrays
  • Remove redundant assignments
  • Remove redundant initializers
  • Remove redundant constructors
  • Remove redundant base constructor invocation
  • Make field read-only (see Making Fields Readonly)
  • Remove redundant jump statements
  • Use array initializer everywhere
  • Remove redundant commas
  • Remove redundant 'string.Format()' calls (see Code Analysis and Helpers for String Literals)
  • Convert to auto-properties (see Using Auto-Properties)
  • Remove attributes
  • Use 'var' or explicit type depending on the code style settings.
  • Remove redundant argument(s) value
  • Remove all empty initializers
  • Remove redundant parenthesis in lambda signatures
  • Remove prohibited modifier(s)
  • Import missing references (see Namespace Imports Assistance)
  • Import item and all other references (see Namespace Imports Assistance)
  • Invoke all methods as extensions
  • Remove 'new' modifiers when not necessary
  • Remove unused directives
  • Remove prohibited modifier(s)
  • Remove redundant '()'
  • Remove redundant as operator calls
  • Remove redundant cast expressions
  • Remove redundant comparisons
  • Remove redundant constructors
  • Remove prohibited modifier(s)
  • Remove prohibited modifier(s)
  • Remove unused labels
  • Remove 'partial' keyword from all types with single part
  • Remove prohibited modifier(s)
  • Remove redundant type specifications
  • Remove redundant 'base()' calls
  • Remove redundant braces in collection initializers
  • Remove redundant delegate constructor calls
  • Remove all redundant else keywords
  • Remove redundant names
  • Remove redundant 'new'
  • Remove redundant parenthesis in attributes
  • Remove redundant 'ToCharArray()' calls
  • Remove redundant conditions in for statements
  • Remove redundant type arguments
  • Remove redundant 'int' in enum declarations
  • Replace 'unsafe' statements with their bodies
  • Remove 'sealed' keyword when it is not applicable
  • Remove redundant anonymous method signatures
  • Remove prohibited modifier(s)
  • Remove redundant 'ToString' method calls (see Code Analysis and Helpers for String Literals)
  • Remove prohibited modifier(s)
  • Remove 'unsafe' modifiers when they are not necessary
  • Rewrite all nullable types

Common

  • Use string interpolation
  • Pass string interpolation
  • Fix naming
  • Adjust namespaces
  • Import missing references
  • Import all types
  • Make fields readonly (see Making Fields Readonly)

VB.NET

  • Make field read-only (see Making Fields Readonly)
  • Remove redundant 'imports'
  • Remove redundant parentheses
  • Remove redundant qualifiers
  • Remove 'ByVal' modifiers
  • To implicitly typed variables

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_available feature_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: 19 August 2016