Skip to content

Update csharp_indent_braces to allow for more fine grained control #63256

@drieseng

Description

@drieseng

The csharp_indent_braces .editorconfig option currently only allows one to enable or disable indent of braces for all code elements.

Would it be possible to allows indenting of braces to be enabled for specific code elements (just as other options like csharp_new_line_before_open_brace have)?

In our team, we indent braces for object initializers, but not for namespaces, types and methods.
For example:

namespace CodeStyle
{
    public class Program
    {
        var x = new Person
            {
                Name = "John",
                Age = 49
            };
        Console.WriteLine(x.Name);
    }
}

Currently it's not possible to configure this style.
We therefore have to disable IDE0055 (dotnet_diagnostic.IDE0055.severity = none) which is quite a pity as we miss out on other useful formatting checks.

I propose to update csharp_indent_braces to allow for the following values:

  • accessors
  • anonymous_methods
  • anonymous_types
  • control_blocks
  • events
  • indexers
  • lambdas
  • local_functions
  • methods
  • object_collection_array_initializers
  • properties
  • types
  • namespaces
  • all
  • none

For compatibility, the current allowed values true and false can remain supported:

  • true can be alias for all that enable braces for all code elements.
  • false can be alias for none that disable braces for all code elements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Complete

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions