6 Replies Last post: Feb 13, 2013 1:58 AM by Tim Sirmovics  
Tim Sirmovics Newbie 8 posts since
Jun 1, 2012
Currently Being Moderated

Feb 7, 2013 1:38 AM

How do I set formatting rules for each clause in linq query syntax to appear on a new line

Hi,

 

I use StyleCop, which includes a readability rule (http://stylecop.soyuz5.com/SA1103.html) stating that all clauses in a linq query must appear on the same line, or on a new line.

 

I run into problems when I use a grouping in query syntax.

 

var result =
                    (from c in collection
                     where c.SomeProperty == true
                     group c by c.SomeOtherProperty
                     into grp select grp.OrderByDescending(c => c.AnotherProperty).First()).ToList();

 

 

I cannot find a way to make R# put the "into" and "select" clauses on a seperate line.

Alex Berezoutsky JetBrains 449 posts since
Feb 18, 2011

Hello Tim,

 

There's a corresponding option in C# Formatter Settings. I've attached an image for a reference.

 

Thanks.

Attachments:
Alex Berezoutsky JetBrains 449 posts since
Feb 18, 2011

Tim,

 

Our forum engine trimmed the code and line breaks.

Could you please attach a *.cs file with the actuall formatting with example how the code is formatted by R# and how'd you like it to be formatted? This will be much appreciated.

 

Thanks in advance!

Alex Berezoutsky JetBrains 449 posts since
Feb 18, 2011

Hi Tim,

 

I've checked that out, and it looks like there's no such option in ReSharper Formatter for now.

 

We apologize for the inconvenience.

Thanks.

More Like This

  • Retrieving data ...