Initializing an inline resharper object

I work with resharper, and when I clear my code, I get this layout:

mock.Setup(m => m.Products).Returns(new List<Product>{new Product{Name = "Football", Price =    25}, new Product{Name = "Surf board", Price = 179}, new Product{Name = "Running Shoes", Price = 95}}.AsQueryable());

I would prefer:

mock.Setup(m => m.Products).Returns(new List<Product>{
    new Product{Name = "Football", Price = 25}, 
    new Product{Name = "Surf board", Price = 179}, 
    new Product{Name = "Running Shoes", Price = 95}
}.AsQueryable());

Is it possible?

+5
source share
5 answers

You can do what you want using the Resharper options (main menu → Resharper → Options).

There are two places you need to see:

Braces Layout> Array and Object InitializerLayout

And here:

Line Breaks and Wrapping> Object and Collection Initializers

+4
source

Yes. Go to Resharper> Tools> Code Editing> C #> Line Breaks and Packaging. Then set the 'wrap object and collection initialiser' to 'chop always'.

It will show you an example of how your option will look in the window below. I am using Resharper 6, but I assume it will be a similar process if you are using an earlier version.

+3

ReSharper Visual Studio "". → # → → . ( Wrap ). "" LinQ .

+1

#. , , , .

0

.

ReSharper -> Options -> Code Editing -> C# -> Formatting Style

VS, , , .

Tools -> Options -> Text Editor -> C# -> Formatting
0

All Articles