Resharper重新格式化Linq语句放入同一行并选择 [英] Resharper reformatting Linq statement to put into and select on same line

查看:87
本文介绍了Resharper重新格式化Linq语句放入同一行并选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我键入Linq查询样式语句时,

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正在将其重新格式化为

Resharper is reformatting it to

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

然后抱怨它,因为它违反了StyleCop规则SA1103.这是Resharper中的错误,还是我需要更改某些设置组合以防止重新格式化?

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?

修改

JetBrains已经确认这是一个错误,已在8.0版中修复.

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

推荐答案

查看ReSharper的选项,在代码编辑"->"C#"->格式设置样式"->->多行构造,LINQ查询"下有一个选项.

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

这似乎可以控制相关的格式(禁用它会导致多行linq查询不按位置对齐,而只是按制表符缩进对齐).

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).

基于对into发生的事情没有更多的控制的事实,我想说这要么是错误,要么是缺少要求.也许要买票.

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.

说实话,我期望在换行和包裹"下找到一些内容,但是对于linq查询没有任何帮助.

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

VS 2012上的ReSharper 7.1.1000.900

这篇关于Resharper重新格式化Linq语句放入同一行并选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆