Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resharper reformatting Linq statement to put into and select on same line

Tags:

c#

linq

resharper

When I type in a Linq query style statement like

var stuff = from x in things
            group x by x.Something into g
            select g;

Resharper is reformatting it to

var stuff = from x in things
            group x by x.Something
            into g select g;

And then complains about it because it breaks the StyleCop rule SA1103. Is this a bug in Resharper or is there some combination of settings that I need to change to keep it from doing this reformatting?

Edit

JetBrains has confirmed that this is a bug and it is fixed in version 8.0.

like image 702
juharr Avatar asked Jun 20 '13 14:06

juharr


1 Answers

Looking at the options for ReSharper, there is a single option under Code Editing -> C# -> Formatting Style -> Other called "Align Multiline Constructs, LINQ query".

This appears to control the relevant formatting (disabling it causes the multi-line linq query to not align by position, but simply by tab indentation).

Based on the fact that there isn't any more granular control over what happens with into, I'd say it's either a bug or a missed requirement on their part. Perhaps raise a ticket.

To be honest I was expecting to find something under "Line Breaks and Wrapping", but nothing was in there for linq queries.

ReSharper 7.1.1000.900 on VS 2012

like image 53
Adam Houldsworth Avatar answered Nov 14 '22 23:11

Adam Houldsworth