因此,Resharper 在重新格式化代码时在我的代码中的“新”之前放置了一个换行符,如下所示:
var foo = new Foo
{
Bar = null,
Baz =
new Baz
{
Bap = null,
Bork = null,
Help =
new PweaseHelp
{
Korben = null,
Dallas = null,
Multipass = null
},
Me =
new ClearlyMyAbilityToUnderstandResharperSettingsIs(
null),
}
};
但我真的很喜欢这样做:
var foo = new Foo
{
Bar = null,
Baz = new Baz
{
Bap = null,
Bork = null,
Help = new PweaseHelp
{
Korben = null,
Dallas = null,
Multipass = null
},
Me = new ClearlyMyAbilityToUnderstandResharperSettingsIs(null),
}
};
我已经深入研究了 .DotSettings 文件中的所有设置,但我无法弄清楚是什么原因造成的......任何帮助将不胜感激:)
编辑 2(更新)
以下是 R# 设置,似乎让我接近我列出的内容,除非您为“包装调用参数”选择“始终切碎”,否则您仍会在等号之后看到新行(使用列出的配置)和“包装对象和集合初始化程序”(如 Kristian 所建议的)。
“始终切碎”的问题在于,您将有非常短的方法调用和对象/集合初始化程序也一直在切碎,这看起来很糟糕,所以我认为我们想要的是:
不要在方法调用/对象/集合初始化程序的等号之后添加新行(但我在任何地方都找不到该设置,因此它可能是 R# 的错误或功能)。
我将尝试在 R# 论坛/支持上提出它并报告我的发现。
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_ARRAY_AND_OBJECT_INITIALIZER/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CONTINUOUS_INDENT_MULTIPLIER/@EntryValue">1</s:Int64>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EMPTY_BLOCK_STYLE/@EntryValue">TOGETHER_SAME_LINE</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_ANONYMOUS_METHOD_BLOCK/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INITIALIZER_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_CODE/@EntryValue">1</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/LINE_FEED_AT_FILE_END/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_TRAILING_COMMENT/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_ARGUMENTS_STYLE/@EntryValue">CHOP_IF_LONG</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/@EntryValue">150</s:Int64>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_OBJECT_AND_COLLECTION_INITIALIZER_STYLE/@EntryValue">CHOP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_PARAMETERS_STYLE/@EntryValue">CHOP_IF_LONG</s:String>