Code Cleanup provides a number of
- Choose ReSharper | Options | Tools | Code Cleanup, or click Ctrl+Alt+F to open the Code Cleanup dialog box.
- Click Edit Profiles.
- In the Code Cleanup tab in the Options dialog box, click Add to create a new custom profile.
- Specify a name for the new profile in the Profile Name dialog box, and click OK.
- Make sure that your new profile is selected in the list of profiles in the Code Cleanup tab.
- Configure profile settings in the Selected profile settings area. See
table below for details on each profile setting. - Click OK.
Whenever you choose to edit a profile or create a new one in ReSharper | Options | Tools | Code Cleanup, ReSharper displays a list of available cleanup settings in the Selected profile settings area:
The settings are listed and explained in the following table.
| Profile setting | Description |
|
C# |
|
|
Arrange 'this' qualifier |
Applies a value selected in the ReSharper | Options | Languages | C# | Formatting Style | Other | Other | Force "this." qualifier for instance member drop-down list and removes redundant |
|
Remove code redundancies |
Overall, ReSharper lists over 70 redundancies in ReSharper | Options | Code Inspection | Inspection Severity that have associated code inspection items. Some of them require special attention, and you simply can't process them in batch mode. That leaves Code Cleanup with about 30 redundancies that it is able to remove automatically, whenever you select Remove code redundancies in your cleanup profile. Specifically, Code Cleanup:
|
|
Use auto-property, if possible |
Replaces simple properties and corresponding backing fields with auto-properties. |
|
Make field read-only, if possible |
Takes action upon "Field can be made readonly" code inspection item. |
|
Use 'var' in declaration |
Provides three options: Replace direction, 'foreach' iterator declaration style, and Local variable declaration style (see below). |
|
Replace direction |
One of three items in the Use 'var' in declaration group of settings. Provides four options:
|
|
'foreach' iterator declaration style |
One of three items in the Use 'var' in declaration group of settings.
Provides three options:
|
|
Local variable declaration style |
One of three items in the Use 'var' in declaration group of settings. Provides five options:
|
|
Update file header |
Inserts or updates file header that you can specify in the ReSharper | Options | Languages | Common | File Header Text tab. |
|
Optimize 'using' directives |
One of three items in the Optimize 'using' directives group of settings. Removes unused namespace import directives; implements settings configured in the ReSharper | Options | Languages | C# | Namespace Imports tab. |
|
Embrace 'using' directives in region |
One of three items in the Optimize 'using' directives group of settings. In every file that a particular Cleanup action covers, this setting creates a new region for holding all namespace import directives. |
|
Region name |
One of three items in the Optimize 'using' directives group of settings. Allows to specify a name for the namespace import region. |
|
Shorten qualified references |
Replaces fully qualified names with short names where possible by importing namespaces, implementing settings configured in the ReSharper | Options | Languages | C# | Namespace Imports tab. |
|
Reformat code |
Reformats you code according to options configurable in ReSharper | Options | Languages | C# | Formatting Style for C# code. |
|
Reformat embedded XML doc comments |
Reformats XML doc comments according to options configurable in ReSharper | Options | Languages | XML | Formatting Style. |
|
Reorder type members |
Reorders type members according to a pattern configurable in ReSharper | Options | Languages | C# | Type Members Layout. |
|
VB.NET |
|
|
Optimize 'import' directives |
Removes unused namespace import directives; implements settings configured in the ReSharper | Options | Languages | Visual Basic .NET | Namespace Imports tab. |
|
Shorten qualified references |
Replaces fully qualified names with short names where possible by importing namespaces, implementing settings configured in the ReSharper | Options | Languages | Visual Basic .NET | Namespace Imports tab. |
|
Reformat code |
Reformats your code according to options configurable in ReSharper | Options | Languages | Visual Basic .NET | Formatting Style for VB.NET code. |
|
XML |
|
|
Reformat code |
Reformats your code according to options configurable in ReSharper | Options | Languages | XML | Formatting Style for XML code. |

for details on simple types).