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'.
Item | Description |
---|---|
'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:
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:
... as well as severity level of the corresponding inspection:
Note that when you change prefernces from the editor, your changes are saved using the smart save logic.
See Also
Procedures:
- Naming Style
- Navigating between Code Issues
- Finding Out What is Wrong with Your Code
- Code Formatting Rules
- File and Type Layout
- File Header Style
- Namespace Imports Assistance
- Implicit/Explicit Typing
- Using Auto-Properties
- Making Fields Readonly
- Attributes Style
- Arranging Modifiers
- Arranging Optional Member Qualifiers
- Reformatting XML Doc Comments
- Removing Code Redundancies