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

 ̄綄美尐妖づ 提交于 2019-12-09 13:05:30

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/17215787/resharper-reformatting-linq-statement-to-put-into-and-select-on-same-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!