You can start with watching this 2-minute overview video where Matt Ellis shows how ReSharper helps you to maintain the entire configuration of formatting rules using EditorConfig.
What is EditorConfig and how does ReSharper extend it?
EditorConfig is a configuration file convention that is used to define and maintain consistent code styles between team members working on the same code as well as between different editors and IDEs that they might use. The styles are saved in INI-like files named .editorconfig, where section names are file masks and properties inside a section define code styles for files matching that masks.
As EditorConfig convention suggests, ReSharper will apply code styles defined in files named .editorconfig in the directory of the current file and in all its parent directories until it reaches the root filepath or finds an EditorConfig file with
root=true. File masks specified in .editorconfig files, e.g.
*Test.cs are also taken into account.
ReSharper understands standard EditorConfig properties, most frequently used .NET-coding-convention EditorConfig properties, and provides a set of custom EditorConfig properties, which allow for much more granular configuration of formatting, syntax, and code inspection rules — in fact, each code style preference that you can configure in the ReSharper options dialog has ist own EditorConfig property. This means that you can maintain the entire configuration of code style and inspection rules in EditorConfig files. Below is an example of EditorConfig properties supported by ReSharper:
EditorConfig in your solution
By default, EditorConfig properties are enabled for code formatting styles and code syntax styles, and disabled for code inspection severity levels; they will override preferences defined in ReSharper and Visual Studio options. If you want ReSharper to ignore EditorConfig styles for code formatting and code syntax, clear the corresponding checkbox on the page of ReSharper options.
To configure code inspections from EditorConfig, you have to select the Read settings from editorconfig... checkbox on the page of ReSharper options.
When EditorConfig support is enabled and there are .editorconfig files that affect the current file, ReSharper will help you understand which EditorConfig styles are applied and where these settings come from:
On ReSharper code style and formatting options pages, you will see a yellow warning if at least one preference on the page is overridden by EditorConfig styles for the current file, each overridden preference will also be highlighted with yellow. For example:
In the File Formatting Info window, you can see and study all .editorconfig files that affect the current file:
Disabling ReSharper formatter with EditorConfig
Standard EditorConfig properties support note
ReSharper will apply the following standard EditorConfig properties:
indent_size property with csharp_indent_size and js_indent_size properties.
.NET-coding-convention properties support note
As of version 2019.1, ReSharper supports most frequently used EditorConfig properties for the .NET coding conventions:
- The following properties for the formatting conventions:
- The following properties for the language conventions:
This feature is supported in the following languages and technologies:
The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see corresponding topics in the ReSharper by Language section.