What is EditorConfig and how does JetBrains Rider 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, JetBrains Rider 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.
JetBrains Rider 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 JetBrains Rider settings 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 JetBrains Rider:
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 JetBrains Rider settings. If you want JetBrains Rider to ignore EditorConfig styles for code formatting and code syntax, clear the corresponding checkbox on the page of JetBrains Rider settings.
To configure code inspections from EditorConfig, you have to select the Read settings from editorconfig... checkbox on the page of JetBrains Rider settings.
When EditorConfig support is enabled and there are .editorconfig files that affect the current file, JetBrains Rider will help you understand which EditorConfig styles are applied and where these settings come from:
On JetBrains Rider 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:
Disabling JetBrains Rider formatter with EditorConfig
Standard EditorConfig properties support note
JetBrains Rider will apply the following standard EditorConfig properties:
.NET-coding-convention properties support note
As of version 2019.1, JetBrains Rider 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: