JetBrains Rider 2020.2 Help

Context Actions for C#

JetBrains Rider provides the following context actions for C#:

NameDescription
Add <exception> tag to XML documentationAdd <exception> tag to XML documentation.
Add <inheritdoc /> tag to XML documentationAdds <inheritdoc /> so that the XML documentation is inherited from the base candidate
Add a name to the current and to the following argumentsAdds a name to the selected and to the following arguments
Add another accessorAdds second accessor to an event or a property.
Add block braces to switch section statementsAdds braces to switch section statements
Add bracesAdds braces to statement
Add deconstruct pattern component nameAdds explicit deconstruction pattern component name based on names in source pattern dispatch type.
Add deconstruct pattern component nameAdds explicit deconstruction pattern component name based on names in source pattern dispatch type.
Add explicit name of anonymous propertyAdds explicit name specification to anonymous type property declaration.
Add name to argumentAdds name to the selected argument.
Add string formatting method argumentAdds new format item to format string and corresponding argument to formatting method invocation
For more information, see Code Analysis and Helpers for String Literals.
Add string interpolation argumentAdds new argument to string interpolation expression. Available over ordinary string literals as well
Add TestCase attributeAdds TestCase attribute to nUnit test method
Add tuple component nameAdds explicit tuple component name based on names in target tuple type.
Add variable designation for type patternIntroduce variable designation for type pattern and possibly replace casts inside corresponding switch section
Annotate enum members with 'EnumMemberAttribute'Adds 'EnumMemberAttribute' to each enum member
Annotate member with nullability attributeAnnotates type member or parameter with nullability attribute.
For more information, see Use Context Actions to add annotation attributes.
Annotate members with 'DataMemberAttribute'Adds 'DataMemberAttribute' to all public properties and fields
Annotate methods with 'OperationContractAttribute'Adds 'OperationContractAttribute' to all exposed methods
Assert reference is not nullAdds assert statement that performs null reference check for a variable at the caret.
Change member visibilityAvailable on an access modifier keyword and allows changing access rights of a declaration.
Check all string parameters for nulls or empty stringsChecks all string parameters for nulls or empty strings
Check all string parameters for nulls or whitespace stringsChecks all string parameters for nulls or whitespace strings
Check array index valueChecks index value for arrays
Check collection index valueChecks index value for collections
Check dictionary key valueChecks key value for dictionaries
Check every parameter for nullChecks all function parameters for null.
Check if enum parameter is defined by enum typeChecks that function parameter is defined by enum type
Check if numeric parameter is out of rangeChecks numeric parameter for specified range
Check if parameter is an empty collectionChecks function parameter for empty collection
Check if parameter is not validChecks function parameter for validity
Check if parameter is nullChecks function parameter for null.
Check if reference is not nullPuts 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 stringChecks string parameter for null or empty string
Check if string parameter is null or whitespace stringChecks string parameter for null or whitespace string
Check if variable is nullChecks variable for null.
Check string index valueChecks index value for strings
Check 'StringBuilder' index valueChecks index value for the 'StringBuilder'
Compute constant valueComputes value of the current expression and replaces it (e.g. 1 + 1 replaced by 2).
Configure null-check assertion patternOpens ReSharper options page to configure null-check pattern.
Configure parameter null-check patternOpens ReSharper options page to configure null-check pattern.
Configure variable null-check patternOpens ReSharper options page to configure null-check pattern.
Convert '?:' conditional expression to 'if' statementConverts conditional expression whose value is returned or assigned to an 'if' statement.
Convert '?:' conditional expression to switch expressionConverts conditional expression whose value is returned or assigned to an switch expression.
Convert '==' operator to 'Equals()' callConverts usage of equality operator ('==') to a call of 'Equals' method.
Convert '==' operator to 'object.ReferenceEquals()' callConverts usage of equality operator ('==') to a call to 'object.ReferenceEquals' method.
Convert anonymous method to lambda expressionConverts anonymous method expression to lambda expression.
Convert anonymous type to named classConverts anonymous type to named class replacing its usages in selected scope.
Convert auto-property to property with default bodyConvert auto-property to property with default body
For more information, see Use Auto-Properties
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 callsReplaces collection initializer with the series of 'Add()' method calls.
Convert compound assignment to regular assignmentConverts compound assignment to regular assignment
Convert constructor to factory methodConverts constructor to factory method and updates usages to factory method call
Convert 'Equals' method call into '==' operator usageConverts a call to instance or static 'Equals' method into usage of equality ('==') or inequality ('!=') operator.
Convert explicit to implicit implementationConverts explicit implementation of an interface method to implicit one.
Convert expression body member to statement bodyConverts expression-bodied member declaration to statement-bodied form
Convert expression lambda to statement lambdaConverts expression-bodied lambda expression to statement-bodied form
Convert 'ForEach' method call to 'foreach' statementConverts 'xs.ForEach(x => ...)' calls into regular 'foreach' statement
Convert 'foreach' to 'for' loopWorks 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 expressionWorks 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 clauseWorks on 'if' statements at the beginning of switch section and splicts it in a guarded section with the 'if' content and unguarded section with the else branch
Convert 'if' statement to 'switch' expressionWorks 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' statementWorks 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 implementationConverts implicit implementation of an interface member to explicit one.
Convert integer literal to binary formConverts integer literal to binary form.
Convert integer literal to hexadecimal formConverts integer literal to hexadecimal form.
Convert integral literal to decimal formConverts integer literal to decimal form.
Convert invalid character literal to stringConvert invalid character literal into string literal
Convert iterator to methodConverts iterator to method or property with List<T> fill or array return
Convert lambda expression to anonymous methodConverts lambda expression to anonymous method expression.
Convert LINQ to codeConverts LINQ to code
Convert LINQ to method chainConverts LINQ query to extension methods call.
Convert method group to anonymous methodConverts method group to anonymous method.
Convert method group to lambdaConverts method group to lambda expression.
Convert null coalescing assignment to if statementConverts null coalescing assignment to if statement
Convert null coalescing expression to 'if' statementConverts null coalescing expression to 'if' statement
Convert object initializer into assignment statementsReplaces object initializer with the series of assignment statements.
Convert 'ReferenceEquals' method call into '==' operator usageConverts a call to static 'ReferenceEquals' method into usage of equality ('==') or inequality ('!=') operator.
Convert statement body member to expression bodyConverts statement-bodied member declaration to expression-bodied form
Convert statement lambda to expression lambdaConverts statement-bodied lambda expression to expression-bodied form
Convert string comparison to 'string.Equals' callConverts string comparison int 'string.Equals' method call
Convert string interpolation to 'string.Format' callConverts string interpolation expression into corresponding 'string.Format' method call
Convert string literal to string interpolationConverts regular or verbatim string to corresponding kind of string interpolation expression.
Convert 'string.Format' to string interpolationConverts 'string.Format' call to string interpolation (even in case that could change the order of arguments evaluation)
Convert switch expression to switch statementConverts switch expression to switch statement.
Convert 'switch' statement to 'if' statementConverts 'switch' statements into one or multiple nested 'if' statements each checking for individual value.
Convert switch statement to switch expressionConverts switch statement to switch expression.
Convert to regular string interpolationConverts verbatim string interpolation $@".." to regular $"..".
For more information, see Code Analysis and Helpers for String Literals.
Convert to regular string literalConverts verbatim string @".." to regular string "..".
For more information, see Code Analysis and Helpers for String Literals.
Convert to 'using' declarationReplace 'using' statement with 'using' declaration
Convert to verbatim string interpolationConverts regular string interpolation $".." to verbatim $@"..".
For more information, see Code Analysis and Helpers for String Literals.
Convert to verbatim string literalConverts regular string literal ".." to verbatim string @"..".
For more information, see Code Analysis and Helpers for String Literals.
Converts member value check expression to recursive patternReplaces member read access to check for some constant value with corresponding pattern
Copy XML documentation from base memberCopies XML documentation from base to overriding members/types
Create another part of a type declarationMarks the type as partial if necessary and creates new part in new file
Create derived typeCreates class that implements interface or inherits class.
Create event invocatorCreates event invocator.
Create overload with selected argument's typeAvailable on method invocation, creates overload with selected argument's type
Create overload without parameterCreates overload without given parameter. Calls current method.
Create return from expressionCreates return statement with value that is taken as an expression statement
Deconstruct variableDeconstructs single variable into multiple variables.
Delete commentDeletes comment
Encapsulate lazy fieldEncapsulating lazy field to property if there is no existing one
Evaluate expressionEvaluates simple expression and replaces it with evaluated value
Extract anonymous method expression to local functionExtracts anonymous method expression into local function in the containing scope.
Extract anonymous method expression to named methodExtracts anonymous method expression into private method of the containing type.
Extract lambda expression to local functionExtracts lambda expression into local function in the containing scope.
Extract lambda expression to named methodExtracts lambda expression into private method of the containing type.
Extract local function to regular methodExtracts local function into regular method in the containing type lifting its closures if necessary.
Fill object initializerInitializes fields and properties in object initializer.
Fix invalid escape sequencesFix invalid escape sequences in string by escaping all characters
Fix invalid regular stringFix invalid characters in string by making it verbatim
Fix regular expressionFix invalid characters in regular expression
For more information, see Regular Expressions Assistance.
Fix ternary expression in string interpolationWraps ternary expression in parentheses in order to prevent interpolated string from interpreting its false branch as format specifier
Flip an invocation expressionFlips the current invocation expression e.g. left.Equals(right) to right.Equals(left).
Flip an operator argumentsFlips left and right operands for selected operator e.g. 'null == list' to 'list == null'.
Flip an relational expressionFlips the current relational expression e.g. 'list.Count > 1' to 'list.Count < 1'.
Fully qualify reference to type, static member or namespaceInsert full qualification for reference to type, static member or namespace
Generate method to check whether enum flagGenerates extension method to check whether enum value contains specified flag
Generate type patternsGenerates type patterns
Implement abstract memberWorks 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 accessorsAdds placeholders for custom implementation of 'add' and 'remove' methods for an event.
Implement 'INotifyPropertyChanged' patternCreates method to invoke 'PropertyChanged' event with string literal parameter and adds ReSharper annotation to enable identifying this method by 'INotifyPropertyChanged' support
Import static members with 'using static' directiveImports static members of type with C# 6.0 'using static' directive in file
Include member access into object patternReplaces member access in source expression of 'is'/'switch' operators with corresponding pattern(s)
Initialize auto-property from constructor parameterOptionally creates and initializes auto-property from constructor parameter.
Initialize field from constructor parameterOptionally creates and initializes field from constructor parameter
Inline control transfer statementInline control transfer statement like 'return' or 'continue' into the statement above
Inline out variable declarationReplaces local variable declaration as declaration expresssion
Inline string interpolation argumentInlines string literal or nested string interpolation into containing interpolated string
Insert anonymous method signatureAdds proper signature to parameterless declaration of an anonymous method.
Insert digit separators in integer literalPlaces 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 literalPlaces digit separators to separate thousands in real literals of float/double/decimal type.
Insert generic method invocation type argumentsInserts inferred type arguments of generic method invocation/delegate creation from method group expression. Available when caret is exactly at the end of method name
Insert lambda expression signatureAdds explicit type specifications for implicitly-typed lambda parameters.
Insert type specification after default literalConverts default literal into default expression.
Introduce variable from standalone expressionIntroduces variable from standalone statement
Invert '?:' operator conditionInverts condition and swaps branches of the '?:' conditional expression.
Invert 'if' statementInverts guard condition of an 'if' statement and swaps the branches' code accordingly.
Invoke extension method as staticChanges invocation syntax from extension method to static method.
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 sectionRearranges attributes into single section
Join local variable declaration and assignmentWorks 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 assignmentReplace 'if' statement with code using ?? operator and throw expression
Join string literalsConcatenates two string literals into one.
Make method partialConverts private void method to partial method definition.
Mark string literal as string interpolationAdds '$' to regular or verbatim string without changes to its content.
Match file name with type nameRenames current file to match the name of the only top-level type declared therein.
Merge deconstructed declarationMerges deconstructed declaration into single variable declaration.
Merge nested 'if' statementsMerges two nested 'if' statements to a single 'if' statement that checks conjunction of the original conditions.
Merge partial method declarationsMerges all declarations of a partial method into single declaration.
Merge partial type declarationsMerges all declarations of a partial type into single declaration.
Merge sequential checks into null-propagating expressionMerge sequential null/type checks using the conditional access expression ('?.' operator)
Move assignment in constructor to initializerMoves assignment from constructor to field/event/property initializer
Move declaration(s) to another type partMoves 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 scopeMoves local variable (with initialization), local constant or local function declaration to outer scope
Move type to another file to match its nameMoves current type to another file so that its name matches the name of the type.
Negate logical expressionNegates logical expression
Notify property changesAdds call to the notification method
Override virtual memberWorks 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 expressionReplaces format method invocation with passing string interpolation expression. Use carefully, since 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 invocationReplaces format method invocation with passing 'string.Format' method call result. Use carefully, since some of format methods (like in logging frameworks) do not always execute the formatting of arguments while 'string.Format' always produces string.
Pull expression from variable initializerPull variable initializer expression to its usage(s)
Push expression to variable initializerPush equivalent variable usage expression(s) to its initializer
Put variable inside 'using' statementConverts variable declaration of type that implements the 'System.IDisposable' interface into 'using' statement. This is useful for enforcing lifetime for disposable objects.
Qualify static members imported via 'using static' directiveInserts type qualification for static members usages imported in scope via C# 6.0 'using static' directive
Remove #region, #endregion directivesRemoves region and corresponding endregion pair of directives
For more information, see Add and Remove #region Blocks.
Remove argument nameRemoves name from selected argument.
Remove bracesRemoves unnecessary braces around one or more statements in the code
Remove digit separators from numeric literalRemoves digit separators from integer or real literals
Remove redundant parenthesisRemoves parenthesis in case they are redundant
Remove string formatting method argumentRemoves format string item and corresponding formatting method argument from format method invocation.
For more information, see Code Analysis and Helpers for String Literals.
Remove tuple component nameRemoves explicit tuple component name in tuple expression.
Replace '.IfNotNull(x => x.Smth)'-like call with '?.' expressionReplace usage of extension methods like '.IfNotNull(x => x.Smth)' with conditional access expression ('?.' operator)
Replace '?:' conditional operator with null-propagating expressionReplaces use of conditional expression ('?:' operator) with null-coalescing (?? operator) or conditional access expression (?. operator)
Replace array initializer with expressionReplaces array initializer with array creation expression.
Replace auto-property with property and backing fieldReplaces auto-property with property that utilizes backing field.
For more information, see Use Auto-Properties
Replace cast expression with safe 'as' castReplace regular cast expression with safe cast 'as' expression.
Replace casts with pattern variableConverts 'if (a is B) {}' to 'if (a is B b) {}' and updates usages
Replace conditional access expression with unconditional accessReplaces conditional access expression ('?.' operator) with regular unconditional access
Replace explicit type specification with 'var'Allows to replace type with 'var' even in the case when doing so would change the type of the variable.
Replace 'if' statement with null-propagationReplace 'if' statement with conditional access expressions (null-propagation)
Replace logical expression with equal expressionInvert logical expression with equal expression
Replace member access with conditional access expressionReplaces member access/invocation or indexer access with conditional access expression ('?.' operator)
Replace null-propagating expression with '?:' conditional operatorReplaces use of null-coalescing ('??' operator) or conditional access expression ('?.' operator) with conditional expression ('?:' operator)
Replace null-propagating expression with 'if' statementReplace C# 6.0 conditional access expression with 'if' statement
Replace property with backing field with auto-propertyReplaces property that utilizes backing field with auto-property.
For more information, see Use Auto-Properties
Replace safe 'as' cast expression with regular castReplace safe 'as' cast expression with regular cast expression.
Replace separate deconstruction declarations with single declarationReplaces separate deconstruction declarations with single declaration
Replace 'var' with explicit type declarationReplace 'var' with explicit type declaration.
Reverse assignment statementReverses source and destination parts of an assignment statement.
Reverse 'for' loop statementReverses order of iteration in 'for' loop statement.
Specify array type explicitlyAdds explicit type specification to array creation expression.
Specify enum member valuesAdd explicit value specifications to all enum members
Split attributes into separate sectionsRearranges attributes into separate sections
Split declaration listWorks 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 clausesWorks on a switch case label which 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'-statementsWorks on an 'if' statement, which 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'-statementsWorks on an 'if' statement, which condition is a disjunction ('||') of two simpler conditions. It converts the 'if' statement into two 'if' statements with equal bodies.
Split local variable declaration and initializationMoves variable initializer expression into separate assignment statement.
Split local variable declaration and initializationMoves variable declaration to outer scope.
Split null-propagating expression into sequential checksSplit conditional access expression ('?.' operator) into sequential null/type checks
Split 'return' statement of boolean value to 'if' statementWorks on an 'return' statement, which value is of boolean type. It converts the 'return' statement into 'if' statement with a two'return' statements, returning 'true' and 'false' values.
Split 'return' with '&&'-condition into guarding 'if' and 'return'Works on a 'return' statement, which value is a conjunction ('&&') of two simpler conditions. It converts the 'return' statement into a guarding 'if' statement and a 'return'.
Split string literalSplits string literal into two literals.
Split value return with '||' condition into 'if' and 'return' statementsWorks on an 'return' statement, which value is a disjunction ('||') of two simpler conditions. It converts the 'return' statement into 'if' and 'return' statements.
Split variable declaration into several onesReplaces variable declaration with several ones declared in inner blocks of the current block.
Surround string literal with 'string.Format' callSurrounds string literal with 'string.Format()' method call.
Surround with ""Creates string literal of selection text.
Test regular expressionOpen dialog to edit and test regular expression against example text
To abstract/virtual/non-abstract/non-virtual memberMakes type member abstract, virtual or non-abstract and non-virtual.
To LINQ to JSONConvert JSON string to JSON.NET object
To LINQ to XMLConvert XML string to LINQ to XML object
To precompiled 'Regex' objectIntroduce field and precompile object of 'Regex' type
For more information, see Regular Expressions Assistance.
UncommentRemoves comments from a code block
Use 'as' and check for nullConverts 'if(a is B) {}' to 'var b = a as B; if(b != null) {}' and updates usages
Use collection initializer instead of 'Add' method callsReplaces series of 'Add()' method calls with collection initializer.
For more information, see Code Inspection: Use object or collection initializer when possible.
Use explicit discard declarationAdds 'var' to discard declaration in order to prevent possible clash with other elements named '_'
Use explicit or implicit tuple component nameAvailable on tuple components references
Use format stringConverts concatenation of a few strings and other objects to the use of String.Format method.
For more information, see Code Analysis and Helpers for String Literals.
Use implicit discard declarationRemoves redundant 'var' keyword from discard declaration
Use object initializer instead of assignmentsReplaces series of assignments with object initializer.
Use separate declarations in deconstruction declaration/patternsReplaces single declaration with separate variable declarations inside deconstruction
Use Span<T> for stack allocated variableUse Span<T> for stack allocated variable
Use string interpolationConverts concatenation of a few strings and other objects to the use of string interpolation.
Use 'System.Environment.NewLine' valueUse 'System.Environment.NewLine' instead of "\n", "\r" or "\r\n" literal.
Use 'System.String.Empty' valueUse 'System.String.Empty' instead of "" literal.
Last modified: 08 May 2020