ReSharper 2016.3 Help

Code Style and Cleanup

ReSharper provides a lot of features for keeping your code neat and clean. Being tightly interwoven with the majority of other ReSharper's features, they help you produce code and change existing codebases according to the specific code style. The code style, which includes naming standards, formatting rules, file layout, file header style, and many other tiny aspects (such as order of modifiers or whether to use the 'var' keyword) can be configured to a very detailed level and shared across your team.

ReSharper uses different approaches to deal with different aspects of the code style. For instance:

  • Using the code inspection, ReSharper detects and highlights symbol names inconsistent with your naming standards, redundancies in your code, and a lot more.
  • Each of the highlighted style violations can be fixed with a quick fix, or the fix in scope can be applied to all violations of this type.
  • Violations of code formatting rules as well as some other minor inconsistencies are not highlighted for the reason of keeping your code readable in the editor. Violations of formatting rules can be easily fixed though - select non-formatted code, press Alt+Enter and choose Format Selection.
  • Code cleanup helps apply formatting rules and many other code style preferences in a bulk mode for the desired scope.
  • Most of your code style preferences are taken into account when ReSharper applies refactorings, code templates or produces generated code.
  • The mechanism of shared settings allows keeping your code style configurations under a VCS and automatically sharing them with your team members.

You can refer to specific topics in this section to learn how exactly ReSharper deals with the corresponding code style aspects.

Most of ReSharper's code style features are available in C# , some are available in several languages, others are language-specific. The table below lists all code style features and languages/technologies where they are supported.

The instructions and examples given in the topics within this section address the use of code style features in C#. For more information on code style features available for specific languages, see the corresponding topics in the ReSharper by Language section.

C# VB.NET C++ HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts Protobuf JSON
Enforcing naming standards /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Enforcing code formatting rules /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg
Implicit/Explicit Typing /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Built-In Type References Style /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Arranging member qualifiers /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Arranging modifiers /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Namespace/module import style /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Include directive style /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
File header style /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Removing code redundancies /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Using auto-properties /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Making fields readonly /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Making auto-properties get-only /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Using Named/Positional Arguments /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Arranging optional parentheses /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Attributes style /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Braces for single nested statements /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Reformatting XML documentation comments /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Reordering type members /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Normalizing quotes /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Terminating statements /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Optimizing reference comments /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Collapsing empty tags /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Alphabetizing properties /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Code Cleanup /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg
Batch-applying code style preferences /help/img/dotnet/2016.3/check.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg /help/img/dotnet/2016.3/cross.svg

See Also

Last modified: 3 April 2017