在Resharper中获取对象和数组初始化器的正确缩进 [英] Get correct indentation in Resharper for object and array initializers

查看:172
本文介绍了在Resharper中获取对象和数组初始化器的正确缩进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,resharper格式化我们的代码像这样:

Right now resharper formats our code like this:

private readonly List<Folder> folders = new List<Folder>
                                        {
                                            new Folder()
                                        };

但我希望它看起来像这样:

but I want it to look like this:

private readonly List<Folder> folders = new List<Folder>
{
    new Folder()
};

我一直在搞乱的选项很多,但似乎无法让他们正确。你可以帮忙吗?

I've been messing with the options a lot, but can't seem to get them right. Can you help?

推荐答案

我对匿名代理有同样的问题。匿名委托格式的修正这里

I had the same issue with anonymous delegates. The fix for anonymous delegate formatting is here:


我终于找到了修复
的方法。格式化
匿名方法的选项分布在
两个单独的页面中ReSharper
选项:大括号布局和其他。
不缩进一个可笑的数量是
在其他页面上,它被称为
缩进匿名方法体。将
关闭,并将括号选项设置为
在行尾,您会得到
更好的东西:

I did finally find the way to fix this. The options for formatting anonymous methods are spread across two separate pages in ReSharper options: Braces Layout and Other. The "don’t indent a ridiculous amount" is on the Other page, and it’s called "Indent anonymous method body". Turn it off, and set the brace option to "At end of line", and you get something much nicer:

但我不知道实例声明集合格式化我害怕。 :(

But i'm not sure about the instance declaration collection formatting i'm afraid. :(

这篇关于在Resharper中获取对象和数组初始化器的正确缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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