When doing something like this:
MyObject tmp = new MyObject();
tmp.Prop = "Hello";
ReSharper tells me to 'Use 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 brace to be on the second line, like this:
MyObject tmp = new MyObject
{
Prop = "Hello"
};
But I can't find any setting for this anywhere. I have the setting 'C# -> Formatting Style -> Braces Layout -> Array and object initializer' set to 'At next line (BSD style)'
Could there be some other setting interfering with this, preventing the formatting I want?
Edit: If I manually format the code like I want it, it will automatically reformat (to the wrong format) when I enter the semi colon.
So I finally found the setting that was messing with the formatting:
Sometimes i need to set the same option in VS and Resharper.
In Resharper it's like 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With