All docs
V21.1
21.1
20.2
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Code Cleanup Rules

  • 3 minutes to read

Code Style

Title Description C# VB[1]
Collapse property accessors Converts all property accessors into a single-line form CRR_IconPassed
Expand property accessors Converts all property accessors into a multi-line form CRR_IconPassed
Collapse property accessors Converts all property accessors into a single-line form CRR_IconPassed
Expand property accessors Converts all property accessors into a multi-line form CRR_IconPassed
Format document[2] Executes the Document Formatting (C#) feature CRR_IconPassed
Make properties auto-implemented Converts properties with fully described accessors to auto-implemented properties CRR_IconPassed CRR_IconPassed
Use expression bodies Converts single-statement properties and methods into expression-bodied structures CRR_IconPassed
Use ‘nameof’ Converts string literals containing a variable or class member name to the nameof expression with the corresponding variable/member as an argument CRR_IconPassed CRR_IconPassed

Layout

Title Description C# VB[1]
Add copyright header Adds a copyright comment at the file’s beginning (configuration) CRR_IconPassed CRR_IconPassed
Organize members Sorts member declarations in the class and removes the redundant line breaks CRR_IconPassed CRR_IconPassed
Sort namespace references Sorts namespace references alphabetically or by length CRR_IconPassed CRR_IconPassed
Sync Namespace with Folder Structure Renames namespaces within a project so they match the project’s folder structure. CRR_IconPassed CRR_IconPassed

Programming Style

Title Description C# VB[1]
Apply ‘Attribute lists’ style[2] Combines attributes into a list or breaks attribute lists apart (according to the corresponding style rule) CRR_IconPassed CRR_IconPassed
Apply ‘Attribute lists’ style to assembly-level attributes[2] Combines assembly-level attributes into a list or breaks attribute lists apart (according to the corresponding style rule) CRR_IconPassed CRR_IconPassed
Apply ‘Braces in statements’ style Adds or removes optional block delimiters to/from all single-statement blocks (according to the corresponding style rule) CRR_IconPassed
Apply built-in type style[2] Converts explicitly-typed variable declarations to implicit or vice versa (according to corresponding style rule). The related Code Action is Make Implicit/Explicit CRR_IconPassed CRR_IconPassed
Apply ‘Optional parenthesis’ style[2] Adds or removes optional parenthesis to/from the selected code elements (according to the corresponding style rule) CRR_IconPassed CRR_IconPassed
Apply ‘this’/‘Me’ qualifier style[2] Adds ‘this’/ ‘Me’ qualifier where required or removes it where possible (according to corresponding style rule) CRR_IconPassed CRR_IconPassed
Apply variable declaration style Converts CLR types to their keyword aliases or vice versa (according to corresponding style rule) CRR_IconPassed CRR_IconPassed
Apply visibility style[2] Adds visibility modifiers where required or removes them where possible (according to corresponding style rule) CRR_IconPassed CRR_IconPassed
Remove redundant braces in blocks without parent statement[2] Deletes optional block delimiters in “floating” code blocks CRR_IconPassed
Sort modifiers[2] Sorts member modifiers according to corresponding style rule CRR_IconPassed

Redundant Code Removal

Title Description C# VB[1]
Remove all comments, excluding XML comments[2] Cleans the code from the non-XML comments CRR_IconPassed CRR_IconPassed
Remove all regions[2] Cleans the code from the #region preprocessor directives CRR_IconPassed CRR_IconPassed
Remove redundant ‘base’/ ‘MyBase’ qualifier[2] Deletes the ‘base’/ ‘MyBase’ qualifier in all member references where it can be omitted CRR_IconPassed CRR_IconPassed
Remove redundant type cast[2] Deletes type casts in the places where they can be omitted CRR_IconPassed CRR_IconPassed
Remove redundant type qualifiers[2] Deletes type qualifiers in the places where they can be omitted and adds the required using/Imports statements CRR_IconPassed CRR_IconPassed

Strings

Title Description C# VB[1]
Convert to String Interpolation Converts all formatted strings into the string interpolations CRR_IconPassed CRR_IconPassed
Convert to string.Empty[2] Converts all empty string literals (“”) into the string.Empty system constant CRR_IconPassed CRR_IconPassed

Unused Code Removal

Title Description C# VB[1]
Remove unused members Deletes unused members CRR_IconPassed CRR_IconPassed
Remove unused namespace references Deletes the unused namespace references CRR_IconPassed CRR_IconPassed
Remove unused parameters Deletes unused method parameters. CRR_IconPassed CRR_IconPassed
Remove unused private types Deletes unused private nested types CRR_IconPassed CRR_IconPassed
Remove unused types Deletes “internal”, “private” and “private protected” nested types, and “internal” regular types CRR_IconPassed CRR_IconPassed
Remove unused variables Deletes unused variables CRR_IconPassed CRR_IconPassed
Replace unused variables with discard Replaces unused variables with a discard. CRR_IconPassed
Footnotes
  1. Visual Basic

  2. This Code Action is available separately.

See Also