How to fix Resharper object initializer indent as method argument

Resharper 2016.2

Current formatting

IEnumerable<Customer> customers = dbCustomers.Select(customer => new Customer { Name = customer.Name, Address = customer.Address, Number = customer.Number }); 

Expected Formatting

 IEnumerable<Customer> customers = dbCustomers.Select(customer => new Customer { Name = customer.Name, Address = customer.Address, Number = customer.Number }); 

What configuration of Resharper 2016.2 can fix this?

Note: the initializer is inside the arguments, not in the variable.

+5
source share
3 answers

It just started working without any changes to the R # settings after upgrading to version 2016.3 .

0
source

It worked for me. Hope this helps!

Go to Resharper -> Options on the Visual Studio menu bar.

In the tree:

Code EditingC #Formatting StyleBracket Layout

In the right pane:

Array and object initializer

  • Expand the list of options.
  • Select At the next Line (BSD style) (third option).

Formatting style

0
source

If someone needs help, try this: Resharper Options → Code Editing → C # → Formatting Style → Other → Uncheck the “Initialize Array, Object, and Collection” box.

Then in: Resharper Options → Code Editing → C # → Formatting Style → Braces Layout → “Array and Object Initializer” = “In the Next Line (BSD Style)”.

You can also do this, which makes it a little nicer: Restarmer options → Code editing → C # → Formatting style → Line breaks and wraps → “Initialize the wrap and collection object” = “Chop if long or multi-line”.

0
source

Source: https://habr.com/ru/post/1261266/


All Articles