JetBrains Fleet 1.42 Help

Configure C# code style with EditorConfig

JetBrains Fleet supports code formatting styles, code syntax styles, C# naming styles, and code inspection severity levels defined in the EditorConfig format.

What is EditorConfig and how does JetBrains Fleet 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 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 those masks.

As EditorConfig convention suggests, JetBrains Fleet 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, for example *Test.cs are also taken into account.

JetBrains Fleet 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 . Below is an example of EditorConfig properties supported by JetBrains Fleet:

root = true [*] # Most of the standard properties are supported indent_size=2 max_line_length=100 # Most frequently used .NET-coding-convention properties are supported csharp_space_between_parentheses=expressions, type_casts, control_flow_statements csharp_style_var_for_built_in_types=true # dotnet_diagnostic rules are supported dotnet_diagnostic.CS1058.severity = hint # JetBrains Fleet custom properties for code formatting styles resharper_csharp_brace_style=next_line resharper_csharp_blank_lines_around_invocable=2 # JetBrains Fleet custom properties for code syntax styles csharp_default_private_modifier=explicit braces_for_ifelse=not_required # JetBrains Fleet custom properties for code inspections resharper_possible_null_reference_exception_highlighting=error resharper_replace_with_string_is_null_or_empty_highlighting=none

Disable JetBrains Fleet formatter with EditorConfig

In C#, you can disable the JetBrains Fleet formatter using EditorConfig masks that have disable_formatter=true.

Standard EditorConfig properties

JetBrains Fleet will apply the following standard EditorConfig properties:

  • indent_size

  • indent_style

  • tab_width

  • max_line_length

  • insert_final_newline

Note that among JetBrains Fleet's custom EditorConfig properties, there are properties that will override the standard properties for specific languages. For example, you can set a default indent size for all languages with indent_size property, and at the same set a different indent size for C# files with csharp_indent_size property.

Custom EditorConfig properties

Custom EditorConfig properties that JetBrains Fleet provides, allow configuring code style and code inspection settings. Properties for code inspections can be found in the List of code inspections in C#. Properties for code style and formatting settings are listed in the child pages of the Reformat C# code topic.

.NET-coding-convention EditorConfig properties

As of version 1.8, JetBrains Fleet supports most frequently used EditorConfig properties for the .NET coding conventions:

Last modified: 26 May 2024