ReSharper 7.1 Object Initializer Formatting

By doing something like this:

MyObject tmp = new MyObject(); tmp.Prop = "Hello"; 

ReSharper tells me, β€œUse an object initializer,” so I let it reformat the code, and I get something like this:

 MyObject tmp = new MyObject { Prop = "Hello" }; 

However, I would like the first bracket to be on the second line, for example:

 MyObject tmp = new MyObject { Prop = "Hello" }; 

But I can’t find anything for this. I have the setting "C # β†’ Formatting Style β†’ Braces Layout β†’ Array and Object Initializer" set to "On the next line (BSD style)"

Could there be some other setting stopping this from preventing the formatting I want?

Edit:. If I manually format the code as I want, it will automatically reformat (in the wrong format) when I enter the half-word.

+7
source share
2 answers

So, I finally found a setting that was messing with formatting:

enter image description here

+9
source

Sometimes I need to set the same option in VS and Resharper.

In Resharper, this is, as you said:

 C# -> Formatting Style -> Braces Layout -> Array and object initializer' set to 'At next line (BSD style) 

In Visual Studio:

 Tools -> Options... -> Text Editor -> C# -> Formatting -> New Lines -> Place open brace on new line for object initialzers 
+4
source

All Articles