ReSharper 8.0 Web Help

The table below lists Code Cleanup settings for all supported languages (C#, VB.NET, JavaScript, XML, HTML, CSS, ASP.NET).

You can edit these settings for custom code cleanup profiles.


Code Cleanup settings

Profile setting Description

ASP.NET

Optimize @Register directives

Removes unused @Register directives.

HTML

Reformat code

Reformats your code according to options configurable in ReSharper | Options | Code Editing | HTML for HTML code.

C#

Arrange 'this' qualifier

Applies a value selected in the ReSharper | Options | Code Editing | C# | Formatting Style | Other | Other | Force "this." qualifier for instance member drop-down list and removes redundant this. qualifiers.

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:

  • Removes:
    • Redundant empty constructors.
    • Explicit integer type specifiers in enumerations.
    • true specifiers in for statements.
    • Redundant type casts.
    • Redundant parentheses from attributes without arguments.
    • Explicit calls to base class constructors without arguments.
    • Redundant boolean comparisons.
    • Redundant braces from collection initializers with a single expression.
    • Redundant explicit delegate creation expressions.
    • Empty argument lists from object/collection initializers.
    • Redundant new keywords.
    • Redundant partial modifiers on type declarations where a type has a single part.
    • Redundant unsafe contexts and statements.
    • Redundant object.ToString() calls (for example, in a concatenation with a string or as an argument of a string.Format() call).
    • Redundant string.ToCharArray() calls.
    • Redundant specifications of argument types.
    • Signatures in anonymous methods where its parameters are not used in the method body.
    • Non-referenced labels.
    • Redundant field initializers.
    • Redundant explicit names in anonymous type properties.
    • Redundant nullable types where value type is implicitly convertible to nullable.
  • Converts:
    • Nullable types to short form (Nullable<T> to T?).
    • Static method invocations to extension method calls where extension methods are invoked as static methods.
    • To implicitly typed array creation expressions when array type can be inferred from initializer.
  • Fixes:
    • Occurrences where static members of a type are accessed via derived members of the type.

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:

  • Do not change (if this value is selected, ReSharper neither converts explicit to implicit types, nor it does the opposite, even if the values of the following two settings imply such conversion).
  • Can change type usage to 'var' (only allows converting explicit to implicit types).
  • Can change 'var' to type usage (only allows converting implicit to explicit types).
  • Can change explicit to 'var' and vice versa (allows conversion in both directions - for example, you can opt to use explicit types in 'foreach' iterators and implicit types in local variables).

'foreach' iterator declaration style

One of three items in the Use 'var' in declaration group of settings.

Provides three options:

  • Always use explicit type
  • Always use 'var'
  • Use 'var' except for built-in types (implements implicit typing for all types except built-in .NET Framework data types).
  • Use 'var' except for simple types (see C# Language Specification: 4.1.4. Simple types for details on simple types).

Local variable declaration style

One of three items in the Use 'var' in declaration group of settings.

Provides five options:

  • Always use explicit type
  • Always use 'var'
  • Use 'var' except for built-in types (implements implicit typing for all types except built-in .NET Framework data types).
  • Use 'var' except for simple types (see C# Language Specification: 4.1.4. Simple types for details on simple types).
  • Use 'var' only when initializer has type usage (var p = new CodeCleanupProfile(false);
    but string n = c.Name;).

Update file header

Inserts or updates file header that you can specify in the ReSharper | Options | Code Editing | 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 | Code Editing | 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 | Code Editing | C# | Namespace Imports tab.

Reformat code

Reformats you code according to options configurable in ReSharper | Options | Code Editing | C# | Formatting Style for C# code.

Reformat embedded XML doc comments

Reformats XML doc comments according to options configurable in ReSharper | Options | Code Editing | XML | Formatting Style.

Reorder type members

Reorders type members according to a pattern configurable in ReSharper | Options | Code Editing | C# | Type Members Layout.

VB.NET

Optimize 'import' directives

Removes unused namespace import directives; implements settings configured in the ReSharper | Options | Code Editing | 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 | Code Editing | Visual Basic .NET | Namespace Imports tab.

Reformat code

Reformats your code according to options configurable in ReSharper | Options | Code Editing | Visual Basic .NET | Formatting Style for VB.NET code.

JavaScript

Terminates statements

Terminates JavaScript statements with the semicolon.

Reformat code

Reformats your code according to options configurable in ReSharper | Options | Code Editing | JavaScript | Formatting Style for XML code.

CSS

Alphabetize properties

Rearranges CSS properties in the alphabetical order.

Reformat code

Reformats your code according to options configurable in ReSharper | Options | Code Editing | CSS | Formatting Style for XML code.

XML

Reformat code

Reformats your code according to options configurable in ReSharper | Options | Code Editing | XML | Formatting Style for XML code.

See Also

Concepts

Procedures

Reference

External Links