ReSharper 10.0 Help

Code Style

ReSharper | Options | Code Editing | C# | Code Style

Preferences configurable on this page affect the behaviour of specific Code Style Assistance features. The preferences are taken into account when ReSharper applies refactorings, code templates or produces generated code. They can be also applied to the existing code by using code cleanup with the corresponding settings.

The preferences with the Notify with selector have corresponding code inspections that notify you if this aspect of the code style in the inspected scope differs from the the preferred style. Using these selectors, you can configure severity levels of the inspections.

If you want some preference not to be checked and not to be applied with the code cleanup, set the severity level to 'Do not show'.

ItemDescription
'var' usage in declarations Preferences in this section define how the implicitly typed local variables (also known as var keyword) should be used. For more information, see Implicit/Explicit Typing.
Instance members qualification Preferences in this section define how to use 'this' qualifier. For more information, see Arranging Optional Member Qualifiers.
Static members qualification Preferences in this section define how to qualify static members. For more information, see Arranging Optional Member Qualifiers.
Built-in type naming The preference in this section defines how to reference C# built-in types: you can either use C# keywords or CLR type names. For more information, see Built-in Type References Style.
Reference qualification Preferences in this section define the style of namespace imports:
  • Prefer fully qualified references - select this check box if you prefer use fully qualified names rather than namespace import directives for imported types.
  • Add 'using' directive to the deepest scope - if this check box is selected, namespace import directives are added inside the namespace where the imported types are used; otherwise the import directives are added in the top of the file.
  • Prefer fully qualified using name at nested scope - if this check box is selected, fully qualified names for imported types are preferred in nested types and namespaces.
  • Allow using alias directive - selecting this check box allows using aliases in namespace import directives, as opposed to fully qualified namespace names.
  • Allow the 'global::' prefix - if this check box is selected, the global:: prefix are not removed, as in global::System.String. For more information, see How to: Use the Global Namespace Alias.

A number of other options related to namespace imports can be configured in the Code Editing | C# | Namespace Imports options page.

Modifiers Preferences in this section define how to arrange modifiers of types and members. For more information, see Arranging Modifiers.
Attributes Preference in this section define how to arrange multiple attribues. For more information, see Attributes Style.

You can also change specific code style preferences right in the editor, by pressing Alt+Enter where style violations are highlighted. For example, you can change the preference of 'var' usage in declarations for simple types:

Changing code style preference for 'var' keyword

... as well as severity level of the corresponding inspection:

Changing inspection severity level

Note that when you change prefernces from the editor, your changes are saved using the smart save logic.

See Also

Last modified: 8 January 2016