Place opening brace at beginning of next line

Answered

I'm trying to make VS2019 and ReSharper work properly together, such that running the VS2019 format command results in no changes when I've run ReSharper's format command.

My current issue is the placement of the opening brace (and the rest of the block actually) for object and array initializers and lambdas.

Consider this piece of code (formatted as I'd like it to be):

Asking VS2019 to format this results in no changes. But running ReSharper format on it results in:

And running VS2019 format on that results in:

Since VS2019 don't format collection initializers well.

 

So basically I'm looking for the setting that makes ReSharper start the block at the beginning of the line, instead of at the syntactical element it logically belongs to.

6 comments
Comment actions Permalink

Try: Code Editing -> C# -> Formatting Style -> Braces Layout -> Array and object initializer: At next line (BSD style)

0
Comment actions Permalink

That's the setting I'm using, and that results in the braces being indented as shown in second image above.

0
Comment actions Permalink

Hello @Kbi!

 

Could you please specify what command do you use for ReSharper formatting? 

Please also provide you ReSharper settings from all layers (here's described how to export settings files). You can share it using 'Submit a request' form.

Thank you.

 

 

0
Comment actions Permalink

Hello!

Disabling ReSharper | Options | Code Editing | C# | Formatting Style | Tabs, Indents, Alignment | Align Multiline Constructs | Array, object and collection initializer should do the trick.

Thank you.

0
Comment actions Permalink

That did the trick. Thanks.

0

Please sign in to leave a comment.