Search code examples
c#resharpercode-formattingrider

How do I stop ReSharper/Rider from doing this: "}, {"


How do I prevent rider from generating }, { between chopped elements of an initialization? I looked through Editor --> Code Style --> Braces Layout/Line Breaks and Wrapping, but I may have missed something. Surely this mildly weird construction is not forced upon us?

What Rider does:

Dictionary<string, string[]> rider = new() {
{
    "first", new[] {
        "a", "b", "c",
        "d", "e", "f"
    }
}, { // <-- Not desired
    "first", new[] {
        "a", "b", "c",
        "d", "e", "f"
    }
};

Preferred:

Dictionary<string, string[]> rider = new() {
{
    "first", new[] {
        "a", "b", "c",
        "d", "e", "f"
    }
},
{   // <-- Want this
    "first", new[] {
        "a", "b", "c",
        "d", "e", "f"
    }
};

My current settings may be wrong: Line Breaks and Wrapping

Braces Layout


Solution

  • Set Expressions (initializers, switch expressions, patterns) to At next line (BSD style):
    enter image description here