Resharper格式化链接方法 [英] Resharper formatting chained method

查看:64
本文介绍了Resharper格式化链接方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

R#中是否存在设置以设置链接方法的格式以从实例化的类的相同字符开始。

Is there a setting in R# to format chained method to start at the same character of the class instantiated.

我想要什么:

var foo = new FooDataBuilder()
              .WithDate(myDate)
              .WithBar(myBar)
              .Build();

R#给我的好处:

var foo = new FooDataBuilder()
    .WithDate(myDate)
    .WithBar(myBar)
    .Build();


推荐答案

使用Resharper 7.1.2,您可以获得以下内容格式:

With Resharper 7.1.2, you can get the following formatting:

var foo = new FooDataBuilder().WithDate(myDate)
                              .WithBar(myBar)
                              .Build();

通过设置以下Resharper选项:

By setting the following Resharper options:

代码编辑-> C#-> 格式样式- > 换行和包装-> 换行-> 包装链接方法调用总是 Chop c

Code Editing->C#->Formatting Style->Line Breaks and Wrapping->Line Wrapping->Wrap chained method calls to Chop always

启用代码编辑-> C#-> 格式化样式 -> 其他-> 对齐多行结构-> 链式调用

enable Code Editing->C#->Formatting Style->Other->Align Multiline Constructs->Chained method calls

除非您手动进行操作,否则我认为您不能与 FooDataBuilder()保持一致。 (这已经得到Jetbrains的@Dmitry Osinovskiy的确认,因此这可能是您最接近想要的东西的地方。)

I don't think you can align with FooDataBuilder() unless you do it manually. (This has been confirmed by @Dmitry Osinovskiy from Jetbrains so this may be the closest you're going to get to what you want.)

这篇关于Resharper格式化链接方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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