Skip to content

Latest commit

 

History

History
1040 lines (554 loc) · 31.4 KB

README.md

File metadata and controls

1040 lines (554 loc) · 31.4 KB

Roslynator Refactorings

Add boolean comparison

  • Syntax: boolean? expression in place where must be boolean expression

Add boolean comparison

Add braces

  • Syntax: do statement, else clause, fixed statement, for statement, foreach statement, if statement, lock statement, using statement, while statement
  • Scope: embedded statement

Add braces

Add braces to if-else

  • Syntax: if-else chain
  • Scope: embedded statement

Add braces to if-else

Add braces to switch section

  • Syntax: switch section
  • Scope: statements

Add braces to switch section

Add braces to switch sections

  • Syntax: switch statement
  • Scope: switch keyword

Add braces to switch sections

Add cast expression

  • Syntax: argument, assignment expression, return statement, variable declaration

Add cast expression

Add cast expression

Add cast expression

Add cast expression

Add default value to parameter

  • Syntax: parameter without default value
  • Scope: identifier

Add default value to parameter

Add default value to return statement

  • Syntax: return statement without expression

Add default value to return statement

Add exception to documentation comment

  • Syntax: throw statement

Add exception to documentation comment

Add identifier to variable declaration

  • Syntax: variable declaration

Add identifier to variable declaration

Add parameter name to argument

  • Syntax: argument list

Add parameter name to argument

Add parameter name to parameter

  • Syntax: parameter
  • Scope: missing identifier

Add parameter name to parameter

Add using directive

  • Syntax: qualified name
  • Scope: selected namespace

Add using directive

Add using static directive

  • Syntax: member access expression (public or internal static class)
  • Scope: selected class name

Add using static directive

Call 'ConfigureAwait(false)'

  • Syntax: awaitable method invocation
  • Scope: method name

Call 'ConfigureAwait(false)'

Call 'To...' method

  • Syntax: argument, assignment expression, return statement, variable declaration

Call 'To...' method

Change explicit type to 'var'

  • Syntax: variable declaration, foreach statement
  • Scope: type

Change explicit type to 'var'

Change method return type to 'void'

  • Syntax: method

Change method return type to 'void'

Change method/property/indexer type according to return expression

  • Syntax: return statement in method/property/indexer

Change method/property/indexer type according to return expression

Change method/property/indexer type according to yield return expression

  • Syntax: yield return statement in method/property/indexer

Change method/property/indexer type according to yield return expression

Change type according to expression

  • Syntax: variable declaration, foreach statement
  • Scope: type

Change type according to expression

Change type according to expression

Change 'var' to explicit type

  • Syntax: variable declaration, foreach statetement
  • Scope: type

Change 'var' to explicit type

Check parameter for null

  • Syntax: parameter
  • Scope: parameter identifier

Check parameter for null

Collapse to initalizer

  • Syntax: object creation followed with assignment(s)

Collapse to initalizer

Comment out member

  • Syntax: method, constructor, property, indexer, operator, event, namespace, class, struct, interface
  • Scope: opening or closing brace

Comment out member

Comment out statement

  • Syntax: do statement, fixed statement, for statement, foreach statement, checked statement, if statement, lock statement, switch statement, try statement, unchecked statement, unsafe statement, using statement, while statement
  • Scope: opening or closing brace

Comment out statement

Copy documentation comment from base member

  • Syntax: constructor, method, property, indexer, event

Copy documentation comment from base member

Create condition from boolean expression

  • Syntax: return statement, yield return statement, expression statement
  • Scope: boolean expression

Create condition from boolean expression

Duplicate argument

  • Syntax: missing argument

Duplicate argument

Duplicate member

  • Syntax: method, constructor, property, indexer, operator, event, namespace, class, struct, interface
  • Scope: opening or closing brace

Duplicate member

Duplicate parameter

  • Syntax: missing parameter

Duplicate parameter

Duplicate statement

  • Syntax: do statement, fixed statement, for statement, foreach statement, checked statement, if statement, lock statement, switch statement, try statement, unchecked statement, unsafe statement, using statement, while statement
  • Scope: opening or closing brace

Duplicate statement

Expand assignment expression

  • Syntax: assignment expression
  • Scope: operator

Expand assignment expression

Expand coalesce expression

  • Syntax: coalesce expression
  • Scope: ?? operator

Expand coalesce expression

Expand event

  • Syntax: event field declaration

Expand event

Expand expression-bodied member

  • Syntax: expression body

Expand expression-bodied member

Expand initializer

  • Syntax: initializer

Expand initializer

Expand lambda expression body

  • Syntax: lambda expression
  • Scope: body

Expand lambda expression body

Expand property

  • Syntax: auto-property

Expand property

Expand property and add backing field

  • Syntax: auto-property

Expand property and add backing field

Extract declaration from using statement

  • Syntax: using statement
  • Scope: declaration

Extract declaration from using statement

Extract expression from condition

  • Syntax: if statement, while statement
  • Scope: condition

Extract expression from condition

Extract generic type

  • Syntax: generic name with single type argument
  • Scope: type argument

Extract generic type

Extract statement(s)

  • Syntax: else clause, fixed statement, for statement, foreach statement, checked statement, if statement, lock statement, try statement, unsafe statement, using statement, while statement

Extract statement(s)

Extract type declaration to a new file

  • Syntax: class declaration, struct declaration, interface declaration, enum declaration, delegate declaration
  • Scope: identifier

Extract type declaration to a new file

Format accessor braces

  • Syntax: get accessor, set accessor, add accessor, remove accessor
  • Scope: block

Format accessor braces

Format accessor braces

Format argument list

  • Syntax: argument list

Format argument list

Format argument list

Format binary expression

  • Syntax: logical and/or expression, bitwise and/or expression

Format binary expression

Format conditional expression

  • Syntax: conditional expression

Format conditional expression

Format conditional expression

Format expression chain

  • Syntax: expression chain

Format expression chain

Format expression chain

Format initializer

  • Syntax: initializer

Format initializer

Format initializer

Format parameter list

  • Syntax: parameter list

Format parameter list

Format parameter list

Generate base constructors

  • Syntax: class declaration
  • Scope: identifier

Generate base constructors

Generate 'OnEvent' method

  • Syntax: event
  • Scope: identifier

Generate 'OnEvent' method

Generate switch sections

  • Syntax: switch statement (that is empty or contains only default section)

Generate switch sections

Initialize local with default value

  • Syntax: local declaration without initializer
  • Scope: identifier

Initialize local with default value

Inline method

  • Syntax: static/extension method invocation

Inline method

Insert string interpolation

  • Syntax: string literal, interpolated string

Insert string interpolation

Insert string interpolation

Introduce and initialize field

  • Syntax: constructor parameter

Introduce and initialize field

Introduce and initialize property

  • Syntax: constructor parameter

Introduce and initialize property

Introduce constructor

  • Syntax: field, property

Introduce constructor

Introduce field to lock on

  • Syntax: lock statement
  • Scope: missing expression

Introduce field to lock on

Make member abstract

  • Syntax: non-abstract indexer/method/property in abstract class
  • Scope: indexer/method/property header

Make member abstract

Mark all members as static

  • Syntax: non-static field/method/property/event in static class

Mark all members as static

Mark member as static

  • Syntax: non-static field/method/property/event in static class

Mark member as static

Merge assignment expression with return statement

  • Syntax: assignment expression followed with return statement

Merge assignment expression with return statement

Merge attributes

  • Syntax: selected attribute lists

Merge attributes

Merge if statements

  • Syntax: selected if statements

Merge if statements

Merge interpolation into interpolated string

  • Syntax: interpolation

Merge interpolation into interpolated string

Merge local declarations

  • Syntax: local declarations with same type

Merge local declarations

Merge string literals

  • Syntax: concatenated string literals

Merge string literals

Merge string literals into multiline string literal

  • Syntax: concatenated string literals

Merge string literals into multiline string literal

Negate binary expression

  • Syntax: logical and/or expression

Negate binary expression

Negate boolean literal

  • Syntax: boolean literal

Negate boolean literal

Negate operator

  • Syntax: !=, &&, ||, <, <=, ==, >, >=

Negate operator

Notify property changed

  • Syntax: property in class/struct that implements INotifyPropertyChanged
  • Scope: setter

Notify property changed

Parenthesize expression

  • Syntax: selected expression

Parenthesize expression

Promote local to parameter

  • Syntax: local declaration in method

Promote local to parameter

Remove all comments

  • Syntax: singleline/multiline comment, singleline/multiline documentation documentation comment

Remove all comments

Remove all comments (except documentation comments)

  • Syntax: singleline/multiline comment

Remove all comments (except documentation comments)

Remove all documentation comments

  • Syntax: singleline/multiline documentation comment

Remove all documentation comments

Remove all member declarations

  • Syntax: namespace, class, struct, interface
  • Scope: opening or closing brace

Remove all member declarations

Remove all preprocessor directives

  • Syntax: preprocessor directive

Remove all preprocessor directives

Remove all region directives

  • Syntax: region directive

Remove all region directives

Remove all statements

  • Syntax: method, constructor, operator
  • Scope: opening or closing brace

Remove all statements

Remove all switch sections

  • Syntax: switch statement
  • Scope: opening or closing brace

Remove all switch sections

Remove braces

  • Syntax: do statement, else clause, fixed statement, for statement, foreach statement, if statement, lock statement, using statement, while statement
  • Scope: block with a single statement

Remove braces

Remove braces from if-else

  • Syntax: if-else chain
  • Scope: embedded statement

Remove braces from if-else

Remove braces from switch section

  • Syntax: switch section
  • Scope: block

Remove braces from switch section

Remove braces from switch sections

  • Syntax: switch statement
  • Scope: switch keyword

Remove braces from switch sections

Remove comment

  • Syntax: singleline/multiline comment, singleline/multiline xml documentation comment

Remove comment

Remove condition from last else clause

  • Syntax: else clause
  • Scope: else keyword

Remove condition from last else clause

Remove directive and related directives

  • Syntax: preprocessor directive, region directive

Remove directive and related directives

Remove empty lines

  • Syntax: selected lines

Remove empty lines

Remove interpolation

  • Syntax: string interpolation
  • Scope: opening or closing brace

Remove interpolation

Remove member

  • Syntax: method, constructor, property, indexer, operator, event, namespace, class, struct, interface
  • Scope: opening or closing brace

Remove member

Remove member declarations above/below

  • Syntax: empty line between member declarations

Remove member declarations above/below

Remove parameter name from argument

  • Syntax: selected argument(s)

Remove parameter name from argument

Remove parentheses

  • Syntax: parenthesized expression
  • Scope: opening or closing parenthesis

Remove parentheses

Remove property initializer

  • Syntax: property initializer

Remove property initializer

Remove region

  • Syntax: region directive

Remove region

Remove statement

  • Syntax: do statement, fixed statement, for statement, foreach statement, checked statement, if statement, lock statement, switch statement, try statement, unchecked statement, unsafe statement, using statement, while statement
  • Scope: open/close brace

Remove statement

Remove statements from switch sections

  • Syntax: selected switch sections

Remove statements from switch sections

Remove using alias directive

  • Syntax: using alias directive
  • Scope: identifier

Remove using alias directive

Rename backing field according to property name

  • Syntax: field identifier inside property declaration

Rename backing field according to property name

Rename identifier according to type name

  • Syntax: foreach statement, local/field/constant declaration
  • Scope: identifier

Rename identifier according to type name

Rename identifier according to type name

Rename method according to type name

  • Syntax: method

Rename method according to type name

Rename parameter according to its type name

  • Syntax: parameter
  • Scope: parameter identifier

Rename parameter according to its type name

Rename property according to type name

  • Syntax: property identifier

Rename property according to type name

Replace "" with 'string.Empty'

  • Syntax: empty string literal

Replace "" with 'string.Empty'

Replace anonymous method with lambda expression

  • Syntax: anonymous method
  • Scope: delegate keyword

Replace anonymous method with lambda expression

Replace 'Any/All' with 'All/Any'

  • Syntax: Any(Func<T, bool> or All(Func<T, bool> from System.Linq.Enumerable namespace
  • Scope: method name

Replace 'Any/All' with 'All/Any'

Replace as expression with cast expression

  • Syntax: as expression
  • Scope: operator

Replace as expression with cast expression

Replace conditional expression with expression

  • Syntax: conditional expression
  • Scope: selected true/false expression

Replace conditional expression with expression

Replace conditional expression with if-else

  • Syntax: conditional expression

Replace conditional expression with if-else

Replace constant with field

  • Syntax: constant declaration

Replace constant with field

Replace 'Count/Length' with 'Length/Count'

  • Syntax: member access expression
  • Scope: name

Replace 'Count/Length' with 'Length/Count'

Replace do statement with while statement

  • Syntax: do statement
  • Scope: do keyword

Replace do statement with while statement

Replace equals expression with string.Equals

  • Syntax: equals expression, not equals expression
  • Scope: operator

Replace equals expression with string.Equals

Replace equals expression with string.IsNullOrEmpty

  • Syntax: equals expression, not equals expression
  • Scope: operator

Replace equals expression with string.IsNullOrEmpty

Replace equals expression with string.IsNullOrWhiteSpace

  • Syntax: equals expression, not equals expression
  • Scope: operator

Replace equals expression with string.IsNullOrWhiteSpace

Replace field with constant

  • Syntax: read-only field

Replace field with constant

Replace for statement with foreach statement

  • Syntax: for statement

Replace for statement with foreach statement

Replace foreach statement with for statement

  • Syntax: foreach statement

Replace foreach statement with for statement

Replace 'HasFlag' with bitwise operation

  • Syntax: Enum.HasFlag method invocation

Replace 'HasFlag' with bitwise operation

Replace if-else with conditional expression

  • Syntax: conditional expression

Replace if-else with conditional expression

Replace if-else with switch statement

  • Syntax: if statement

Replace if-else with switch statement

Replace increment operator with decrement operator

  • Syntax: prefix/postfix unary expression

Replace increment operator with decrement operator

Replace interpolated string with interpolation expression

  • Syntax: interpolated string with single interpolation and no text
  • Scope: interpolation

Replace interpolated string with interpolation expression

Replace interpolated string with string literal

  • Syntax: Interpolated string without any interpolation

Replace interpolated string with string literal

Replace method invocation with '[]'

  • Syntax: First/Last/ElementAt method invocation
  • Scope: method name

Replace method invocation with '[]'

Replace method with property

  • Syntax: method
  • Scope: method header

Replace method with property

Replace null literal expression with default expression

  • Syntax: argument

Replace null literal expression with default expression

Replace prefix operator to postfix operator

  • Syntax: prefix/postfix unary expression

Replace prefix operator to postfix operator

Replace property with method

  • Syntax: read-only property
  • Scope: property header

Replace property with method

Replace regular string literal with verbatim string literal

  • Syntax: regular string literal

Replace regular string literal with verbatim string literal

Replace string literal with character literal

  • Syntax: string literal

Replace string literal with character literal

Replace 'string.Empty' with ""

  • Syntax: string.Empty

Replace 'string.Empty' with ""

Replace 'string.Format' with interpolated string

  • Syntax: string.Format method

Replace 'string.Format' with interpolated string

Replace switch statement with if-else

  • Syntax: switch statement
  • Scope: switch keyword

Replace switch statement with if-else

Replace verbatim string literal with regular string literal

  • Syntax: verbatim string literal

Replace verbatim string literal with regular string literal

Replace verbatim string literal with regular string literals

  • Syntax: multiline verbatim string literal

Replace verbatim string literal with regular string literals

Replace while statement with do statement

  • Syntax: while statement
  • Scope: while keyword

Replace while statement with do statement

Reverse for loop

  • Syntax: for statement

Reverse for loop

Simplify lambda expression

  • Syntax: lambda expression with block with single single-line statement
  • Scope: body

Simplify lambda expression

Split attributes

  • Syntax: selected attribute list

Split attributes

Split variable declaration

  • Syntax: local declaration, field declaration, event field declaration

Split variable declaration

Swap expressions in binary expression

  • Syntax: logical and/or expression
  • Scope: binary operator

Swap expressions in binary expression

Swap expressions in conditional expression

  • Syntax: conditional expression
  • Scope: condition

Swap expressions in conditional expression

Swap member declarations

  • Syntax: empty line between member declarations

Swap member declarations

Swap statements in if-else

  • Syntax: if statement
  • Scope: if keyword

Swap statements in if-else

Uncomment

  • Syntax: single-line comment(s)

Uncomment

Use expression-bodied member

  • Syntax: method, property, indexer, operator
  • Scope: body or accessor list

Use expression-bodied member

Wrap in #if directive

  • Syntax: selected lines

Wrap in #if directive

Wrap in condition

  • Syntax: selected statements

Wrap in condition

Wrap in region

  • Syntax: selected lines

Wrap in region

Wrap in try-catch

  • Syntax: selected statements

Wrap in try-catch

Wrap in using statement

  • Syntax: local declaration of type that implements IDisposable

Wrap in using statement