Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix ReSharper indentation on object & other initializers

I have found other duplicates of this question, but they are very old and the solutions are not applicable to R#8, because the settings have changed.

When I do anonymous type or object initialization (any kind of curly brace indentation with content), I want it to be BSD style:

var test = new CustomType
{
    Prop1 = value1,
    Prop2 = value2,
};

...and I set R# Options / Code Editing / C# / Formatting Style / Braces Layout / Array and object initializer to "At next line (BSD style)". However, when I hit enter after adding a new curly brace, I still end up with this:

var test = new CustomType
           {
               Prop1 = value1,
               Prop2 = value2,
           };

...which I believe is Whitesmiths style.

What do I need to do to get R# 8 to not indent braces for initializers?

like image 404
danludwig Avatar asked Nov 27 '13 15:11

danludwig


1 Answers

There are two settings that together govern this:

  • Array, object and collection initializers: false

Option1

  • Array and Object Initializer: BSD Style

Option2

Update from OP

These settings may have to be set for "This Computer", not just for personal or team-shared options.

like image 157
jessehouwing Avatar answered Nov 05 '22 17:11

jessehouwing