ReSharper 2024.3 Help

Context actions for C#

ReSharper provides the following context actions for C#:

Name

Description

Add <exception> tag to XML documentation

Adds <exception> tag to XML documentation

Add <inheritdoc /> tag to XML documentation

Adds <inheritdoc /> so that the XML documentation is inherited from the base candidate

Add another accessor

Adds second accessor to an event or a property

Add block braces to switch section statements

Adds braces to switch section statements

Add braces

Adds braces to statement

Add deconstruct pattern component name

Adds explicit deconstruction pattern component name based on names in the source pattern dispatch type

Add explicit name of anonymous property

Adds explicit name specification to anonymous type property declaration

Add explicit 'return' or 'continue' before local function

Add an explicit control flow jump before local functions at the end of a member or a cycle in order to clearly separate executable code from helper functions

Add name to argument

Adds name to the selected argument

Add 'params' modifier to last parameter

Add 'params' modifier to the last parameter and update method usages by passing ad-hoc collections

Add string formatting method argument

Adds a new format item to format string and the corresponding argument to formatting method invocation

For more information, refer to code analysis and helpers for string literals.

Add string interpolation argument

Adds new argument to string interpolation expression. Also available over ordinary string literals.

Add TestCase attribute

Adds TestCase attribute to NUnit test method

Add tuple component name

Adds explicit tuple component name based on names in the target tuple type

Add variable designation for pattern

Introduces variable designation for type test/null-checking/relational pattern and possibly replaces casts inside the corresponding 'switch' section

Add warning description comment to a '#pragma' directive

Adds a comment with a warning description to a '#pragma' directive that disables or restores the warning by its ID

Add/remove extra quotes and dollars in raw string literal

Change the number of quotes or dollar signs in a raw string

Adds 'switch' condition component

Adds 'switch' expression/statement component

Annotate enum members with 'EnumMemberAttribute'

Adds 'EnumMemberAttribute' to each enum member

For more information, refer to using context actions to add annotation attributes.

Annotate member with nullability attribute

Annotates type member or parameter with nullability attribute

For more information, refer to using context actions to add annotation attributes.

Annotate members with 'DataMemberAttribute'

Adds 'DataMemberAttribute' to all public properties and fields

For more information, refer to using context actions to add annotation attributes.

Annotate methods with 'OperationContractAttribute'

Adds 'OperationContractAttribute' to all exposed methods

For more information, refer to using context actions to add annotation attributes.

Assert reference is not null

Adds assert statement that performs null reference check for a variable at the caret

Change between 'set' and 'init' accessor

Changes between 'set' and 'init' accessor kinds

Change member visibility

Available on an access modifier keyword and allows changing access rights of a declaration

Change signature of the current member

Changes signature of the current member

Change type declaration kind between 'class'/'struct' and 'record'

Changes type declaration kind between 'class'/'struct' and 'record' possibly fixing some errors

Check all string parameters for nulls or empty strings

Checks all string parameters for nulls or empty strings

Check all string parameters for nulls or whitespace strings

Checks all string parameters for nulls or whitespace strings

Check array index value

Checks index value for arrays

Check collection index value

Checks index value for collections

Check dictionary key value

Checks key value for dictionaries

Check every parameter for null

Checks all function parameters for null

Check if enum parameter is defined by enum type

Checks that function parameter is defined by enum type

Check if numeric parameter is out of range

Checks numeric parameter for specified range

Check if parameter is an empty collection

Checks function parameter for empty collection

Check if parameter is not valid

Checks function parameter for validity

Check if parameter is null

Checks function parameter for null

Check if reference is not null

Puts the current statement under an 'if' statement that performs null reference check for a variable at the caret

Check if string parameter is null or empty string

Checks string parameter for null or empty string

Check if string parameter is null or whitespace string

Checks string parameter for null or whitespace string

Check if variable is null

Checks variable for null

Check Span<T> index value

Checks index value for Span<T>/ReadOnlySpan<T> types

Check string index value

Checks index value for strings

Check 'StringBuilder' index value

Checks index value for the 'StringBuilder'

Compute constant value

Computes the value of the current expression and replaces it (e.g. 1 + 1 replaced by 2)

Configure null-check assertion pattern

Opens ReSharper options page to configure null-check pattern

Configure parameter null-check pattern

Opens ReSharper options page to configure null-check pattern

Configure variable null-check pattern

Opens ReSharper options page to configure null-check pattern

Construct string via 'StringBuilder'

Converts string literal to 'StringBuilder' creation with the corresponding 'Append' call

Convert '?:' conditional expression to 'if' statement

Converts conditional expression whose value is returned or assigned to an 'if' statement

Convert '?:' conditional expression to 'switch' expression

Converts conditional expression whose value is returned or assigned to a 'switch' expression

Convert '==' operator to 'Equals()' call

Converts usage of equality operator ('==') to a call of 'Equals' method

Convert '==' operator to 'object.ReferenceEquals()' call

Converts usage of equality operator ('==') to a call to 'object.ReferenceEquals' method

Convert anonymous method to lambda expression

Converts anonymous method expression to lambda expression

Convert anonymous type to named type

Converts anonymous type to named type and replaces its usages in the selected scope

Convert anonymous type to tuple

Converts anonymous type to tuple expression and replaces its usages in the containing method

Convert array creation or collection initialization into collection expression

Convert array creation or collection initialization expressions into C# 12 collection expression form

Convert auto-property to property with default body

Converts auto-property to a property with default body

For more information, refer to use auto-properties

Convert between text and string escape sequences

Convert between text and various forms of string escape sequences

Convert 'catch (Exception)' clause to 'catch'

Converts 'catch (System.Exception)' clause into 'catch' form

Convert 'catch' clause to 'catch (Exception)'

Converts 'catch' clause into 'catch (System.Exception)' form

Convert collection initializer into 'Add' method calls

Replaces collection initializer with the series of 'Add()' method calls

Convert compound assignment to regular assignment

Converts compound assignment to regular assignment

Convert constructor to factory method

Converts constructor to factory method and updates usages to factory method call

Convert current extension method into ordinary static method form

Converts current extension method into ordinary static method form by removing 'this' modifier and updating all method usages

Convert current method into extension method form

Convert current method into extension method form by adding 'this' modifier and updating all the method usages

Convert 'Equals' method call into '==' operator usage

Converts a call to instance or static 'Equals' method into usage of equality ('==') or inequality ('!=') operator

Convert explicit to implicit implementation

Converts explicit implementation of an interface method to implicit one

Convert expression body member to statement body

Converts expression-bodied member declaration to statement-bodied form

Convert expression lambda to statement lambda

Converts expression-bodied lambda expression to statement-bodied form

Convert expression to 'StringBuilder'

Converts expression to 'StringBuilder'

Convert expression to 'StringBuilder' calls

Converts expression inside 'StringBuilder' into the corresponding 'StringBuilder' calls

Convert 'ForEach' method call to 'foreach' statement

Converts 'xs.ForEach(x => ...)' calls into regular 'foreach' statement

Convert 'foreach' to 'for' loop

Works on 'foreach' statements executed on a collection that allows direct access to its elements by index. It converts such 'foreach' statement to 'for' statement.

Convert 'if' statement to '?:' conditional expression

Works on 'if' statement that returns value or performs assignment inside each branch. It converts the statement to a conditional expression ('x ? a : b').

Convert 'if' statement to switch case guard clause

Works on 'if' statements at the beginning of a switch section and splits it into a guarded section with the 'if' content and unguarded section with the else branch

Convert 'if' statement to 'switch' expression

Works on 'if' statements that perform type checks or compare value of an expression with one or more constants. It converts 'if' statements into a single 'switch' expression.

Convert 'if' statement to 'switch' statement

Works on 'if' statements that perform type checks or compare value of an expression with one or more constants. It converts 'if' statements into a single 'switch' statement.

Convert implicit to explicit interface implementation

Converts implicit implementation of an interface member to an explicit one

Convert integer literal to binary form

Converts integer literal to the binary form

Convert integer literal to the hexadecimal form

Converts integer literal to the hexadecimal form

Convert integral literal to decimal form

Converts integer literal to the decimal form

Convert into list pattern

Converts a collection length check into a list pattern (e.g. 'x is { Length: 0 }' -> 'x is []')

Convert invalid character literal to string

Converts invalid character literal into string literal

Convert iterator to method

Converts iterator to method or property with List<T> fill or array return

Convert lambda expression to anonymous method

Converts lambda expression to anonymous method expression

Convert LINQ to code

Converts LINQ to code

Convert LINQ to method chain

Converts LINQ query to extension methods call

Convert member value check expression to recursive pattern

Replaces member read access to check for some constant value with the corresponding pattern

Convert method group to anonymous method

Converts method group to anonymous method

Convert method group to lambda

Converts method group to lambda expression

Convert method to property

Converts parameterless method with a return value into property declaration

Convert multiline string to separate 'AppendLine' calls

Converts a multiline string inside 'StringBuilder' into separate 'AppendLine' calls

Convert not-null check into object pattern check

Converts a not-null check expression into a pattern-matching check

Convert null coalescing assignment to if statement

Converts null coalescing assignment to if statement

Convert null coalescing expression to 'if' statement

Converts null coalescing expression to 'if' statement

Convert object initializer into assignment statements

Replaces object initializer with the series of assignment statements

Convert object initializer into constructor invocation

Replaces object initializer with invocation of constructor with parameters matching by name and type

Convert property to method

Converts property into method declaration

Convert 'ReferenceEquals' method call into '==' operator usage

Converts a call to static 'ReferenceEquals' method into usage of equality ('==') or inequality ('!=') operator

Convert regular to raw string interpolation

Converts regular string interpolation to raw

Convert regular to raw string literal

Converts regular verbatim string literal to raw string

Convert statement body member to expression body

Converts statement-bodied member declaration to the expression-bodied form

Convert statement lambda to expression lambda

Converts statement-bodied lambda expression to the expression-bodied form

Convert string comparison to 'string.Equals' call

Converts string comparison into a 'string.Equals' method call

Convert string interpolation to 'string.Format' call

Converts string interpolation expression into the corresponding 'string.Format' method call

Convert string literal to string interpolation

Converts regular or verbatim string into the corresponding kind of string interpolation expression

Convert 'string.Format' to string interpolation

Converts 'string.Format' call to string interpolation (even if that could change the order of arguments evaluation)

Convert 'switch' expression to conditional ?: expression(s)

Converts 'switch' expression to a series of conditional (ternary) ?: expressions

Convert 'switch' expression to 'if' statements

Converts 'switch' expression into one or multiple nested 'if' statements each checking for individual pattern

Convert 'switch' expression to 'switch' statement

Converts 'switch' expression to 'switch' statement

Convert 'switch' statement to 'if' statements

Converts 'switch' statements into one or multiple nested 'if' statements each checking for individual pattern

Convert 'switch' statement to 'switch' expression

Converts 'switch' statement to 'switch' expression

Convert to array creation expression

Replaces C# 12 collection expression with array creation expression syntax

Convert to collection initializer

Replaces C# 12 collection expression with collection initializer syntax

Convert to 'global using'

Converts selected 'using' directives to global ones and moves them into a separate file

Convert to non-global 'using'

Moves 'using' directives from a separate file to all project files where its necessary

Convert to regular string interpolation

Converts verbatim string interpolation $@".." to regular $".."

For more information, refer to code analysis and helpers for string literals.

Convert to regular string literal

Converts verbatim string @".." to regular string ".."

For more information, refer to code analysis and helpers for string literals.

Convert to separate 'Append' and 'AppendLine' invocations

Converts a single 'AppendLine' invocation into separate 'Append' and 'AppendLine' invocations

Convert to top-level code

Replaces the 'Program' class and a 'Main' method with top-level code

Convert to 'try-finally' statement

Convert a 'using' statement to 'try-finally' statement

Convert to 'using' declaration

Replaces 'using' statement with 'using' declaration

Convert to 'using' statement

Replaces 'using' variable declaration with 'using' statement

Convert to verbatim string interpolation

Converts regular string interpolation $".." to verbatim $@".."

For more information, refer to code analysis and helpers for string literals.

Convert to verbatim string literal

Converts regular string literal ".." to verbatim string @".."

For more information, refer to code analysis and helpers for string literals.

Convert verbatim to raw string interpolation

Converts verbatim string interpolation to raw

Convert verbatim to raw string literal

Converts verbatim string literal to raw string

Convert 'with' expression into temporary variable mutations

Copy a structure or record to a local variable, modify its members, and use this variable instead of the 'with' expression

Copy current type declaration

Changes signature of the current member

Copy XML documentation from base member

Copies XML documentation from base to overriding members/types

Create another part of a type declaration

Marks the type as partial if necessary and creates a new part in a new file

Create collection expression from 'params' parameter arguments

Creates collection expression from 'params' parameter arguments

Create derived type

Creates class that implements interface or inherits class

Create event invocator

Creates event invocator method

Create explicit array creation from 'params' parameter arguments

Creates explicit array creation from 'params' parameter arguments

Create explicit collection creation from 'params' parameter arguments

Creates explicit collection creation from 'params' parameter arguments

Create explicit constructor declaration for primary constructor

Create explicit constructor declaration for primary constructor of a record

Create explicit field declaration for parameter of primary constructor

Creates explicit field declaration for parameter of primary constructor

Create explicit property declaration for positional parameter

Creates explicit property declaration for positional parameter of a record

Create matching checked operator

Creates matching checked operator

Create overload without parameter

Creates overload without given parameter. Calls current method.

Create return from expression

Creates return statement with value that is taken as an expression statement

Create Unit Test

Creates a test class for a target class

Deconstruct variable

Deconstructs variable into multiple positional components

Delete comment

Deletes selected comment

Delete comment

Deletes comment

Enable "Enforce braces in 'do-while' statement" inspection

Suggests enabling "Enforce braces in 'do-while' statement" inspection when the caret is on 'do', 'while' keywords

Enable "Enforce braces in 'fixed' statement" inspection

Suggests enabling "Enforce braces in 'fixed' statement" inspection when the caret is on 'fixed' keyword

Enable "Enforce braces in 'fixed' statement" inspection

Suggests enabling "Enforce braces in 'fixed' statement" inspection when the caret is on 'fixed' keyword

Enable "Enforce braces in 'for' statement" inspection

Suggests enabling "Enforce braces in 'for' statement" inspection when the caret is on 'for' keyword

Enable "Enforce braces in 'foreach' statement" inspection

Suggests enabling "Enforce braces in 'foreach' statement" inspection when the caret is on 'foreach' keyword

Enable "Enforce braces in 'if' statement" inspection

Suggests enabling "Enforce braces in 'if' statement" inspection when the caret is on 'if', 'else' keywords

Enable "Enforce braces in 'lock' statement" inspection

Suggests enabling "Enforce braces in 'lock' statement" inspection when the caret is on 'lock' keyword

Enable "Enforce braces in 'using' statement" inspection

Suggests enabling "Enforce braces in 'using' statement" inspection when the caret is on 'using' keyword

Enable "Enforce braces in 'while' statement" inspection

Suggests enabling "Enforce braces in 'while' statement" inspection when the caret is on 'while' keyword

Enable "Suppress nullable warning with '!'" quick-fix in current solution

Suggests enabling 'Suppress nullable warning with '!'' quick-fix for the current solution when the caret is on a '!' token

Enable 'A suppressed nullable warning might hide an underlying problem' inspection

Suggests enabling 'A suppressed nullable warning might hide an underlying problem' inspection when the caret is on '!' operator

Enable 'Local function can be made static' inspection

Suggests enabling 'Local function can be made static' inspection when the caret is on local function 'static' keyword

Enable 'Struct member can be made readonly' inspection

Suggests enabling 'Struct member can be made readonly' inspection when the caret is on a 'readonly' keyword

Enable 'Unnecessary whitespace at the end of line' inspection

Suggests enabling 'Unnecessary whitespace at the end of line' inspection when the caret is on trailing whitespace

Enable 'Usage of tabulation character for indentation is prohibited' inspection

Suggests enabling 'Usage of tabulation character for indentation is prohibited' inspection when the caret is on a whitespace with tab character

Encapsulate lazy field

Encapsulates lazy field to property if there is no existing one

Evaluate expression

Evaluates simple expression and replaces it with evaluated value

Extract anonymous method expression to local function

Extracts anonymous method expression into a local function in the containing scope

Extract anonymous method expression to named method

Extracts anonymous method expression into a private method of the containing type

Extract lambda expression to local function

Extracts lambda expression into a local function in the containing scope

Extract lambda expression to named method

Extracts lambda expression into a private method of the containing type

Extract local function to regular method

Extracts a local function into a regular method in the containing type and lifts its closures if necessary

Extract method from selected code

Creates a new method, property, or local function from the selected expression or statements, and replaces the selection with the function call

Fill object initializer

Initializes fields and properties in object initializer

Find nullable warning suppressions

Finds all nullable warning suppression expressions in the selected scope

Fix invalid escape sequences

Fixes invalid escape sequences in the string by escaping all characters

Fix invalid regular string

Fixes invalid characters in the string by making it verbatim

Fix regular expression

Fixes invalid characters in regular expression

For more information, refer to code analysis and helpers for string literals.

Fix ternary expression in string interpolation

Wraps ternary expression in parentheses to prevent interpolated string from interpreting its false branch as format specifier

Flip invocation expression

Flips the current invocation expression e.g. 'left.Equals(right)' to 'right.Equals(left)'

Flip operator arguments

Flips left and right operands for selected operator e.g. 'null == list' to 'list == null'

Flip relational expression

Flips the current relational expression e.g. 'list.Count > 1' to '1 < list.Count'

Fully qualify reference to type, static member, or namespace

Inserts full qualification for reference to type, static member, or namespace

Generate extension method to check enum flag

Generates extension method to check whether the enum value contains the specified flag

Generate type patterns

Generates type patterns

Implement abstract member

Works on an interface member or an abstract member. Searches for classes where this member needs to be implemented and allows implementing it in one of them.

Implement custom event accessors

Adds placeholders for custom implementation of 'add' and 'remove' methods for an event

Implement 'INotifyPropertyChanged' pattern

Creates method to invoke 'PropertyChanged' event with string literal parameter

For more information, refer to using context actions to add annotation attributes.

Import static members with 'using static' directive

Imports static members of type with C# 6.0 'using static' directive in file

Include member access into object pattern

Replaces member access in source expression of 'is'/'switch' operators with corresponding pattern(s)

Initialize auto-property from constructor parameter

Optionally creates and initializes auto-property from constructor parameter

Initialize field from constructor parameter

Optionally creates and initializes field from constructor parameter

Initialize member from constructor parameter

Optionally creates a constructor and initializes the member from a constructor parameter

Initialize non-private field from constructor parameter

Initializes non-private field from constructor parameter

Inline control transfer statement

Inlines control transfer statement like 'return' or 'continue' into the statement above

Inline out variable declaration

Replaces local variable declaration as declaration expression

Inline string interpolation argument

Inlines string literal or nested string interpolation into the containing interpolated string

Inline temporary variable

Inline temporary variable initialized with a value of other variable/parameter to reduce the amount of different names that address the same value

Inline using alias

Inlines 'using' alias into contexts where it is used

Inline variable into condition expression

Inlines variable into condition expression, resulting in a pattern matching

Insert anonymous method signature

Adds proper signature to parameterless declaration of an anonymous method

Insert digit separators in integer literal

Places digit separators in common places of integer literals: separates thousands in decimal literals, 16-bit words in hexadecimal literals, bytes in binary literals

Insert digit separators in real literal

Places digit separators to separate thousands in real literals of float/double/decimal type

Insert generic method invocation type arguments

Inserts inferred type arguments of generic method invocation/delegate creation from method group expression. Available when the caret is exactly at the end of method name.

Insert lambda expression parameters signature

Adds explicit type specifications for implicitly-typed lambda parameters

Insert lambda expression return type specification

Adds explicit return type specifications for lambda expression

Insert type specification after default literal

Converts default literal into default expression

Introduce parameter for selected expression

Creates a new parameter for the selected expression

Introduce type alias

Introduce 'using' alias for selected type

Introduce variable for selected expression

Creates a new variable for the selected expression

Invert '?:' operator condition

Inverts condition and swaps branches of the '?:' conditional expression

Invert 'if' statement

Inverts guard condition of an 'if' statement and swaps the branches' code accordingly

Invoke extension method as ordinary static method

Changes invocation syntax from extension method to static method invocation form

Iterate via 'await foreach'

Generates an 'await foreach' statement iterating the expression

Iterate via 'foreach'

Generates a 'foreach' statement iterating the expression

Iterate via 'foreach' (based on Live Template)

Generates a 'foreach' statement iterating the expression

Join attributes into single section

Rearranges attributes into single section

Join local variable declaration and assignment

Works on an assignment to a variable that was declared without initializer. Moves the declaration to the current point and merges it with the assignment.

Join null check with assignment

Replaces 'if' statement with code using '??' operator and 'throw' expression

Join string literals

Concatenates two string literals into one

Lift a local function closure to parameter

Converts a local function closure over a containing method's local variable into the local function's parameter

Make method partial

Converts private void method to partial method definition

Mark string literal as string interpolation

Adds '$' to regular or verbatim string without changes to its content

Match file name with type name

Renames current file to match the name of the only top-level type declared therein

Merge deconstructed declaration

Merges deconstructed declaration into single variable declaration

Merge nested 'if' statements

Merges two nested 'if' statements to a single 'if' statement that checks conjunction of the original conditions

Merge partial method declarations

Merges all declarations of a partial method into single declaration

Merge partial type declarations

Merges all declarations of a partial type into single declaration

Merge sequential checks into null-propagating expression

Merges sequential null/type checks using the conditional access expression ('?.' operator)

Merge sequential null/pattern checks into single pattern check

Merges sequential null/pattern checks into single recursive/logical pattern check

Migrate to #nullable enable

Migrates [NotNull]/[CanBeNull] attributes to compiler #nullable context and type annotations

Move a local function to the end of containing scope

Move a local function to the end of containing scope in order to clearly separate executable code from declaration of a helper function. Separate with an explicit control flow jump such as 'return' or 'continue' when possible.

Move assignment in constructor to initializer

Moves assignment from constructor to field/event/property initializer

Move declaration(s) to another type part

Moves selected declarations range or a single declaration (if invoked without selection on declaration name) to another type part of a partial type

Move initialization to constructor(s)

Moves field/event/property initializers to constructor(s)

Move local variable, constant, or function declaration to outer scope

Moves local variable (with initialization), local constant, or local function declaration to outer scope

Move type to another file to match its name

Moves current type to another file so that its name matches the name of the type

Negate logical expression

Negates logical expression

Override virtual member

Works on a virtual member. Searches for classes where this member can be overridden and allows overriding it in one or all of them.

Pass string interpolation expression

Replaces format method invocation with passing string interpolation expression. Use carefully, because some of format methods (like in logging frameworks) do not always execute the formatting of arguments while string interpolation expression always evaluates.

Pass 'string.Format' method invocation

Replaces format method invocation with passing 'string.Format' method call result. Use carefully, because some of format methods (like in logging frameworks) do not always execute the formatting of arguments while 'string.Format' always produces string.

Put variable inside 'using'

Converts a variable declaration of type that implements 'System.IDisposable', 'System.IAsyncDisposable', or the disposable pattern into a 'using' statement. This is useful for enforcing lifetime for disposable objects.

Qualify static members imported via 'using static' directive

Inserts type qualification for static members usages imported in scope via C# 6.0 'using static' directive

Remove #region, #endregion directives

Removes #region and corresponding #endregion pair of directives

For more information, refer to add and remove #region blocks.

Remove argument name

Removes name from selected argument

Remove braces

Removes unnecessary braces around one or more statements in the code

Remove deconstruct pattern component name

Removes explicit deconstruction pattern component name based on names in the source pattern dispatch type

Remove digit separators from numeric literal

Removes digit separators from integer or real literals

Remove 'params' modifier from last parameter

Remove 'params' modifier from the last parameter and update method usages

Remove redundant parenthesis

Removes parenthesis in case they are redundant

Remove string formatting method argument

Removes format string item and corresponding formatting method argument from format method invocation

For more information, refer to code analysis and helpers for string literals.

Remove 'switch' condition component

Removes 'switch' expression/statement component

Remove tuple component name

Removes explicit tuple component name in tuple expression

Replace '.IfNotNull(x => x.Smth)'-like call with '?.' expression

Replaces usage of extension methods like '.IfNotNull(x => x.Smth)' with conditional access expression ('?.' operator)

Replace '?:' conditional operator with null-propagating expression

Replaces a conditional expression ('?:' operator) with null-coalescing (?? operator) or conditional access expression (?. operator)

Replace array initializer with expression

Replaces array initializer with array creation expression

Replace auto-implemented property accessor with explicitly implemented accessor

Replaces an auto-implemented accessor without body with an explicitly implemented accessor

Replace auto-property with property and backing field

Replaces auto-property with property that uses a backing field

Replace auto-property with property and 'field' keyword

Replaces auto-property with property that uses an anonymous field

Replace call chain with separate calls

Replaces call chain with separate calls for each method and introduces variable if necessary

Replace cast expression with safe 'as' cast

Replaces regular cast expression with safe cast 'as' expression

Replace conditional access expression with unconditional access

Replaces conditional access expression ('?.' operator) with regular unconditional access

Replace explicit type specification with 'var'

Allows replacing type with 'var' even if doing so would change the type of the variable

Replace 'field' keyword with explicit field declaration

Replaces 'field' keyword in property declaration with explicit field declaration

Replace 'if' statement with null-propagation

Replaces 'if' statement with conditional access expressions (null-propagation)

Replace logical expression with equal expression

Inverts logical expression with equal expression

Replace member access with conditional access expression

Replaces member access/invocation or indexer access with conditional access expression ('?.' operator)

Replace null-propagating expression with '?:' conditional operator

Replaces null-coalescing ('??' operator) or conditional access expression ('?.' operator) with conditional expression ('?:' operator)

Replace null-propagating expression with 'if' statement

Replaces a C# 6.0 conditional access expression with 'if' statement

Replace property with backing field with auto-property

Replaces property that utilizes backing field with auto-property

For more information, refer to use auto-properties

Replace safe 'as' cast expression with regular cast

Replaces safe 'as' cast expression with regular cast expression

Replace separate deconstruction declarations with single declaration

Replaces separate deconstruction declarations with single declaration

Replace 'var' with explicit type declaration

Replaces 'var' with explicit type declaration

Replace with access expression

Replace trivial recursive pattern with a regular or conditional property access expression

Reverse assignment statement

Reverses source and destination parts of an assignment statement

Reverse 'for' loop statement

Reverses order of iteration in 'for' loop statement

Reverse 'for' loop statement

Reverses order of iteration in 'for' loop statement

Set project 'ConfigureAwait' analysis mode

Sets project 'ConfigureAwait' analysis mode

Set project language level

Sets project language level

Sort 'using' directives

Sorts 'using' directives in files according to syntax style settings

Specify array type explicitly

Adds explicit type specification to array creation expression

Specify created type

Specifies created type explicitly

Specify enum member values

Adds explicit value specifications to all enum members

Split 'and' patterns into multiple 'is' expressions or guard expression

Splits logical 'and' patterns into a sequence of 'is' expressions or guard expression

Split attributes into separate sections

Rearranges attributes into separate sections

Split call chain into two parts

Splits call chain into two parts, starting from the method call at caret and introduces variable if necessary

Split declaration list

Works on variable declaration statement that declares multiple variables. It splits such statement into multiple statements each declaring a single variable.

Split guard clause with '||'-condition into two case labels with guard clauses

Works on a switch case label whose guard clause is a disjunction ('||') of two simpler conditions. It converts the switch case label into two separate labels.

Split 'if' with '&&'-condition into nested 'if'-statements

Works on an 'if' statement, whose condition is a conjunction ('&&') of two simpler conditions. It converts the 'if' statement into two nested 'if' statements.

Split 'if' with '||'-condition into two 'if'-statements

Works on an 'if' statement, whose condition is a disjunction ('||') of two simpler conditions. It converts the 'if' statement into two 'if' statements with equal bodies.

Split into nested patterns

Creates a separate recursive pattern to match on a nested property

Split list pattern into several consecutive checks

Extracts subpatterns of a list pattern into checks joined by the '&&' operator

Split local variable declaration and initialization

Moves variable initializer expression into separate assignment statement

Split local variable declaration and initialization

Moves variable declaration to outer scope

Split null-propagating expression into sequential checks

Splits conditional access expression ('?.' operator) into sequential null/type checks

Split 'or' patterns into multiple 'is' expressions or 'switch' cases

Splits logical 'or' patterns into sequence of 'is' expressions or multiple 'switch' cases

Split recursive pattern into several consecutive checks

Extracts subpatterns of a recursive pattern into checks joined by the '&&' operator

Split 'return' statement of boolean value to 'if' statement

Works on a 'return' statement, whose value is of the boolean type. It converts the 'return' statement into an 'if' statement with two 'return' statements, returning 'true' and 'false' values.

Split 'return' with '&&'-condition into guarding 'if' and 'return'

Works on a 'return' statement, whose value is a conjunction ('&&') of two simpler conditions. It converts the 'return' statement into a guarding 'if' statement and a 'return'.

Split string literal

Splits string literal into two literals

Split tuple assignment into separate assignment statements

Splits a statement with tuple assignment or declaration into separate statements

Split value return with '||' condition into 'if' and 'return' statements

Works on a 'return' statement, whose value is a disjunction ('||') of two simpler conditions. It converts the 'return' statement into 'if' and 'return' statements.

Split 'var' pattern into separate variable declaration

Splits 'var' pattern into variable declaration in a separate statement

Surround string literal with 'string.Format' call

Surrounds string literal with 'string.Format()' method call

Surround with ""

Creates string literal of selection text

To abstract/virtual/non-abstract/non-virtual member

Makes type member abstract, virtual, non-abstract, or non-virtual

To block-scoped namespace

Converts file-scoped to block-scoped namespace

To explicit 'Program' class

Replaces the top level code with the explicit 'Program' class and 'Main' method

To file-scoped namespace

Converts namespace with block body to file-scoped namespace

To LINQ to JSON

Converts JSON string to JSON.NET object

To LINQ to XML

Converts XML string to a 'LINQ to XML' object

To named property patterns

Replaces positional deconstruction patterns clause with named property patterns over corresponding members

To precompiled 'Regex' object

Introduces a field and a precompile object of 'Regex' type

For more information, refer to regular expressions assistance.

To property with INotifyPropertyChanged change notification

Converts auto-property to property with 'INotifyPropertyChanged' change notification calls in setter

For more information, refer to inotifypropertychanged support.

Transform parameters

Transforms parameters and return value

Uncomment

Removes comments from a code block

For more information, refer to comment and uncomment code.

Use 'as' and check for null

Converts 'if (a is B) { }' to 'var b = a as B; if (b != null) { }' and updates usages

Use 'ConfigureAwait(false)' call

Adds 'ConfigureAwait(false)' call to a task-like expression in 'await' context

Use explicit discard declaration

Adds 'var' to discard declaration to prevent possible clash with other elements named '_'

Use explicit or implicit tuple component name

Switches between explicit and implicit tuple component name. Available on tuple components references.

Use format string

Converts concatenation of a few strings and other objects to the use of 'String.Format' method

For more information, refer to code analysis and helpers for string literals.

Use implicit discard declaration

Removes redundant 'var' keyword from discard declaration

Use 'MinBy' or 'MaxBy'

Use 'MinBy' or 'MaxBy' instead of ordering and taking 'First' or 'Last'

Use 'nameof' expression to capture name of entity

Uses 'nameof' expression to capture the name of an entity instead of hard-coding it in a string literal

Use object/collection initializer instead of assignments/.Add() method calls

Replaces series of assignments or 'Add()' invocations with object or collection initializer expression

For more information, refer to code inspection: use object or collection initializer when possible.

Use positional deconstruction pattern

Replaces property pattern member(s) of recursive pattern with positional deconstruction patterns

Use separate declarations in deconstruction declaration/patterns

Replaces single declaration with separate variable declarations inside deconstruction

Use Span<T> for stack allocated variable

Uses Span<T> for stack allocated variable

Use string interpolation

Converts concatenation of a few strings and other objects to the use of string interpolation

Use 'System.Environment.NewLine' value

Uses 'System.Environment.NewLine' instead of "\n", "\r" or "\r\n" literal

Use 'System.String.Empty' value

Uses 'System.String.Empty' instead of "" literal

Use target-typed new

Simplifies 'new' expression by removing explicit type specification

Use type alias

Use selected type alias where possible

Use 'var (...)' syntax for deconstructing declarations with multiple variables

Allows replacing a declaration with multiple variables with explicit types with 'var (...)' syntax, making them all implicitly typed

Write documentation

Write XML documentation for declaration

Last modified: 11 February 2024