ReSharper 2017.1 Help

C# - Line Breaks

Preserve Existing Formatting

Keep existing line breaks

Property names:

[resharper_]csharp_keep_user_linebreaks, [resharper_]keep_user_linebreaks

Possible values:

true | false

Examples:

Before formatting After formatting, true
int·var·condition ··SomeFunc1() ··SomeFunc2();
int·var·condition ····SomeFunc1() ····SomeFunc2();
Before formatting After formatting, false
int·var·condition ··SomeFunc1() ··SomeFunc2();
int·var·condition·SomeFunc1()·SomeFunc2();

Break line in single embedded statement

Property names:

[resharper_]csharp_simple_embedded_statement_style, [resharper_]simple_embedded_statement_style

Possible values:

  • line_break: Force line breaks
  • on_single_line: Force put on single line
  • do_not_change: Do not change

Examples:

Before formatting After formatting, line_break
{ ··if·(conditionDoSomething(); ··if·(condition1) ····DoSomething1(); }
{ ····if·(condition) ········DoSomething(); ····if·(condition1) ········DoSomething1(); }
Before formatting After formatting, on_single_line
{ ··if·(conditionDoSomething(); ··if·(condition1) ····DoSomething1(); }
{ ····if·(conditionDoSomething(); ····if·(condition1DoSomething1(); }
Before formatting After formatting, do_not_change
{ ··if·(conditionDoSomething(); ··if·(condition1) ····DoSomething1(); }
{ ····if·(conditionDoSomething(); ····if·(condition1) ········DoSomething1(); }

Break line in single "case" statement

Property names:

[resharper_]csharp_simple_case_statement_style, [resharper_]simple_case_statement_style

Possible values:

  • line_break: Force line breaks
  • on_single_line: Force put on single line
  • do_not_change: Do not change

Examples:

Before formatting After formatting, line_break
switch(foo{ ··case·1return·a; ··case·2: ····return·b; }
switch·(foo) { ····case·1: ········return·a; ····case·2: ········return·b; }
Before formatting After formatting, on_single_line
switch(foo{ ··case·1return·a; ··case·2: ····return·b; }
switch·(foo) { ····case·1return·a; ····case·2return·b; }
Before formatting After formatting, do_not_change
switch(foo{ ··case·1return·a; ··case·2: ····return·b; }
switch·(foo) { ····case·1return·a; ····case·2: ········return·b; }

Break line in a block with a single statement

Property names:

[resharper_]csharp_simple_embedded_block_style, [resharper_]simple_embedded_block_style

Possible values:

  • line_break: Force line breaks
  • on_single_line: Force put on single line
  • do_not_change: Do not change

Examples:

Before formatting After formatting, line_break
{ ··if·(conditionDoSomething();·} ··if·(condition1) ··{ ····DoSomething1(); ··} }
{ ····if·(condition) ····{ ········DoSomething(); ····} ····if·(condition1) ····{ ········DoSomething1(); ····} }
Before formatting After formatting, on_single_line
{ ··if·(conditionDoSomething();·} ··if·(condition1) ··{ ····DoSomething1(); ··} }
{ ····if·(conditionDoSomething();·} ····if·(condition1DoSomething1();·} }
Before formatting After formatting, do_not_change
{ ··if·(conditionDoSomething();·} ··if·(condition1) ··{ ····DoSomething1(); ··} }
{ ····if·(conditionDoSomething();·} ····if·(condition1) ····{ ········DoSomething1(); ····} }

Place on New Line

Place "else" on new line

Property names:

csharp_new_line_before_else, new_line_before_else

Possible values:

true | false

Examples:

true
if·(condition) { ····foo(); } else { ····foo(); }
false
if·(condition) { ····foo(); else { ····foo(); }

Place "while" on new line

Property names:

[resharper_]csharp_new_line_before_while, [resharper_]new_line_before_while

Possible values:

true | false

Examples:

true
do { ····foo(); } while·(condition);
false
do { ····foo(); while·(condition);

Place "catch" on new line

Property names:

csharp_new_line_before_catch, new_line_before_catch

Possible values:

true | false

Examples:

true
try { ····foo(); } catch·(Exception·e) { ····foo(); } finally { }
false
try { ····foo(); catch·(Exception·e) { ····foo(); } finally { }

Place "finally" on new line

Property names:

csharp_new_line_before_finally, new_line_before_finally

Possible values:

true | false

Examples:

true
try { ····foo(); } catch·(Exception·e) { ····foo(); } finally { }
false
try { ····foo(); } catch·(Exception·e) { ····foo(); finally { }

Line Wrapping

Right margin (columns)

Property names:

csharp_max_line_length, max_line_length

Possible values:

an integer

Wrap formal parameters

Property names:

[resharper_]csharp_wrap_parameters_style, [resharper_]wrap_parameters_style

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

chop_always
void·SomeMethod(int·p1, ····int·p2, ····int·p3, ····int·p4) { }
chop_if_long
void·SomeMethod(int·p1, ····int·p2, ····int·p3, ····int·p4) { }
wrap_if_long
void·SomeMethod(int·p1int·p2, ····int·p3int·p4) { }

Prefer wrap before "(" in declaration

Property names:

[resharper_]csharp_wrap_before_declaration_lpar, [resharper_]wrap_before_declaration_lpar

Possible values:

true | false

Examples:

true
void·SomeMethod (int·p1int·p2int·p3, ····int·p4) { }
false
void·SomeMethod(int·p1int·p2, ····int·p3int·p4) { }

Prefer wrap after "(" in declaration

Property names:

[resharper_]csharp_wrap_after_declaration_lpar, [resharper_]wrap_after_declaration_lpar

Possible values:

true | false

Examples:

true
void·SomeMethod( ····int·p1int·p2int·p3, ····int·p4) { }
false
void·SomeMethod(int·p1int·p2, ····int·p3int·p4) { }

Wrap invocation arguments

Property names:

[resharper_]csharp_wrap_arguments_style, [resharper_]wrap_arguments_style

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

chop_always
CallMethod(arg1, ····arg2, ····arg3, ····arg4, ····arg5);
chop_if_long
CallMethod(arg1, ····arg2, ····arg3, ····arg4, ····arg5);
wrap_if_long
CallMethod(arg1arg2arg3, ····arg4arg5);

Prefer wrap before "(" in invocation

Property names:

[resharper_]csharp_wrap_before_invocation_lpar, [resharper_]wrap_before_invocation_lpar

Possible values:

true | false

Examples:

true
CallMethod (arg1arg2arg3arg4, ····arg5);
false
CallMethod(arg1arg2arg3, ····arg4arg5);

Prefer wrap after "(" in invocation

Property names:

[resharper_]csharp_wrap_after_invocation_lpar, [resharper_]wrap_after_invocation_lpar

Possible values:

true | false

Examples:

true
CallMethod( ····arg1arg2arg3arg4, ····arg5);
false
CallMethod(arg1arg2arg3, ····arg4arg5);

Prefer wrap before ","

Property names:

[resharper_]csharp_wrap_before_comma, [resharper_]wrap_before_comma

Possible values:

true | false

Examples:

true
CallMethod(arg1arg2arg3 ····arg4arg5arg6arg7);
false
CallMethod(arg1arg2arg3, ····arg4arg5arg6arg7);

Prefer wrap after "."

Property names:

[resharper_]csharp_wrap_after_dot_in_method_calls, [resharper_]wrap_after_dot_in_method_calls

Possible values:

true | false

Examples:

true
obj.Method(). ····Method(). ····Method(). ····Method(). ····Method(). ····Method(). ····Method(). ····Method(). ····Method(). ····Method();
false
obj.Method() ····.Method() ····.Method() ····.Method() ····.Method() ····.Method() ····.Method() ····.Method() ····.Method() ····.Method();

Wrap chained method calls

Property names:

[resharper_]csharp_wrap_chained_method_calls, [resharper_]wrap_chained_method_calls

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

chop_always
obj.Method() ········.Method()·+ ····obj.Method() ········.Method() ········.Method() ········.Method() ········.Method() ········.Method() ········.Method() ········.Method() ········.Method() ········.Method();
chop_if_long
obj.Method().Method()·+ ····obj.Method() ········.Method() ········.Method() ········.Method() ········.Method() ········.Method() ········.Method() ········.Method() ········.Method() ········.Method();
wrap_if_long
obj.Method().Method()·+ ····obj.Method().Method() ········.Method().Method() ········.Method().Method() ········.Method().Method() ········.Method().Method();

Prefer wrap before ":"

Property names:

[resharper_]csharp_wrap_before_extends_colon, [resharper_]wrap_before_extends_colon

Possible values:

true | false

Examples:

true
class·Derived ····BaseClassI1I2I3I4 { }
false
class·Derived·BaseClassI1, ····I2I3I4 { }

Wrap extends/implements list

Property names:

[resharper_]csharp_wrap_extends_list_style, [resharper_]wrap_extends_list_style

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

chop_always
class·Derived·BaseClass, ····I1, ····I2, ····I3, ····I4 { }
chop_if_long
class·Derived·BaseClass, ····I1, ····I2, ····I3, ····I4 { }
wrap_if_long
class·Derived·BaseClassI1, ····I2I3I4 { }

Wrap "for" statement header

Property names:

[resharper_]csharp_wrap_for_stmt_header_style, [resharper_]wrap_for_stmt_header_style

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

chop_always
for·(int·initial; ····loopLimit; ····i++) { }
chop_if_long
for·(int·initial; ····loopLimit; ····i++) { }
wrap_if_long
for·(int·initial; ····loopLimiti++) { }

Prefer wrap before "?" and ":" in ternary expressions

Property names:

[resharper_]csharp_wrap_before_ternary_opsigns, [resharper_]wrap_before_ternary_opsigns

Possible values:

true | false

Examples:

true
return ····hereGoesSomeBoolExpression ········returnThisIfTrue ········returnThatIfFalse;
false
return ····hereGoesSomeBoolExpression·? ········returnThisIfTrue·: ········returnThatIfFalse;

Wrap ternary expression

Property names:

[resharper_]csharp_wrap_ternary_expr_style, [resharper_]wrap_ternary_expr_style

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

chop_always
myField·someCondition ····true ····false;
chop_if_long
myField·someCondition ····true ····false;
wrap_if_long
myField·someCondition·true ····false;

Wrap multiple declaration

Property names:

[resharper_]csharp_wrap_multiple_declaration_style, [resharper_]wrap_multiple_declaration_style

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

chop_always
class·C { ····public·int·0, ········0, ········2, ········3, ········4, ········5; }
chop_if_long
class·C { ····public·int·0, ········0, ········2, ········3, ········4, ········5; }
wrap_if_long
class·C { ····public·int·00, ········234, ········5; }

Wrap LINQ expressions

Property names:

[resharper_]csharp_wrap_linq_expressions, [resharper_]wrap_linq_expressions

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

chop_always
var·result·from·in·list ····where·cond(x) ····select·x;
chop_if_long
var·result·from·in·list ····where·cond(x) ····select·x;
wrap_if_long
var·result·from·in·list ····where·cond(xselect·x;

Prefer wrap before operator in binary expression

Property names:

[resharper_]csharp_wrap_before_binary_opsign, [resharper_]wrap_before_binary_opsign

Possible values:

true | false

Examples:

true
myField1·expression1 ···········expression2 ···········expression3 ···········expression4 ···········expression5 ···········expression6 ···········expression7;
false
myField1·expression1·+ ···········expression2·+ ···········expression3·+ ···········expression4·+ ···········expression5·+ ···········expression6·+ ···········expression7;

Wrap chained binary expressions

Property names:

[resharper_]csharp_wrap_chained_binary_expressions, [resharper_]wrap_chained_binary_expressions

Possible values:

  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

chop_if_long
!=·&& ····!=·&& ····&& ····f.IsSumOf(gh&& ····i.Value·==·&& ····==·&& ····==·&& ····==·p;
wrap_if_long
!=·&&·!=·&&·&& ····f.IsSumOf(gh&& ····i.Value·==·&&·==·&& ····==·&&·==·p;

Force chop compound condition in "if" statement

Property names:

[resharper_]csharp_force_chop_compound_if_expression, [resharper_]force_chop_compound_if_expression

Possible values:

true | false

Examples:

true
if·(var1·==·null·|| ····var2·==·null) ····Foo();
false
if·(var1·==·null·||·var2·==·null) ····Foo();

Force chop compound condition in "while" statement

Property names:

[resharper_]csharp_force_chop_compound_while_expression, [resharper_]force_chop_compound_while_expression

Possible values:

true | false

Examples:

true
while·(var1·==·null·|| ·······var2·==·null) ····Foo();
false
while·(var1·==·null·||·var2·==·null) ····Foo();

Force chop compound condition in "do" statement

Property names:

[resharper_]csharp_force_chop_compound_do_expression, [resharper_]force_chop_compound_do_expression

Possible values:

true | false

Examples:

true
do { ····Foo(); while·(var1·==·null·|| ·········var2·==·null);
false
do { ····Foo(); while·(var1·==·null·||·var2·==·null);

Wrap multiple type parameter constraints

Property names:

[resharper_]csharp_wrap_multiple_type_parameer_constraints_style, [resharper_]wrap_multiple_type_parameer_constraints_style

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

chop_always
class·C<T1T2T3where·T1·I1 ····where·T2·new() ····where·T3·class
chop_if_long
class·C<T1T2T3where·T1·I1 ····where·T2·new() ····where·T3·class
wrap_if_long
class·C<T1T2T3where·T1·I1·where·T2·new() ····where·T3·class

Wrap object and collection initializer

Property names:

[resharper_]csharp_wrap_object_and_collection_initializer_style, [resharper_]wrap_object_and_collection_initializer_style

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

chop_always
new·C() { ····PropertyX·1, ····PropertyY·2, ····PropertyZ·3 }
chop_if_long
new·C() { ····PropertyX·1, ····PropertyY·2, ····PropertyZ·3 }
wrap_if_long
new·C() { ····PropertyX·1PropertyY·2, ····PropertyZ·3 }

Wrap array initializer

Property names:

[resharper_]csharp_wrap_array_initializer_style, [resharper_]wrap_array_initializer_style

Possible values:

  • chop_always: Chop always
  • chop_if_long: Chop if long or multiline
  • wrap_if_long: Simple wrap

Examples:

chop_always
new·C[] { ····Element1, ····ElementX, ····ElementY, ····ElementZ, ····ElementZzz }
chop_if_long
new·C[] { ····Element1, ····ElementX, ····ElementY, ····ElementZ, ····ElementZzz }
wrap_if_long
new·C[] { ····Element1ElementXElementY, ····ElementZElementZzz }

Prefer wrap before first constraint

Property names:

[resharper_]csharp_wrap_before_first_type_parameter_constraint, [resharper_]wrap_before_first_type_parameter_constraint

Possible values:

true | false

Examples:

true
class·C<T1T2T3> ····where·T1·I1 ····where·T2·new() ····where·T3·class
false
class·C<T1T2T3where·T1·I1 ····where·T2·new() ····where·T3·class

Prefer wrap before type parameters opening angle

Property names:

[resharper_]csharp_wrap_before_type_parameter_langle, [resharper_]wrap_before_type_parameter_langle

Possible values:

true | false

Examples:

true
class·C <Type1Type2Type3, ····Type4> { }
false
class·C<Type1Type2Type3, ····Type4> { }

Other

Place abstract/auto property/indexer/event declaration on single line

Property names:

[resharper_]csharp_place_abstract_accessorholder_on_single_line, [resharper_]csharp_place_simple_blocks_on_single_line, [resharper_]place_abstract_accessorholder_on_single_line, [resharper_]place_simple_blocks_on_single_line

Possible values:

true | false

Examples:

true
interface·I { ····int·Property·getset} }
false
interface·I { ····int·Property ····{ ········get; ········set; ····} }

Place simple property/indexer/event declaration on single line

Property names:

[resharper_]csharp_place_simple_accessorholder_on_single_line, [resharper_]csharp_place_simple_blocks_on_single_line, [resharper_]place_simple_accessorholder_on_single_line, [resharper_]place_simple_blocks_on_single_line

Possible values:

true | false

Examples:

true
class·C { ····int·Property·get·return·xset·value} }
false
class·C { ····int·Property ····{ ········get·return·x} ········set·value} ····} }

Place it on single line even when it has attributes on accessors

Property names:

[resharper_]csharp_place_accessor_with_attrs_holder_on_single_line, [resharper_]csharp_place_simple_blocks_on_single_line, [resharper_]place_accessor_with_attrs_holder_on_single_line, [resharper_]place_simple_blocks_on_single_line

Possible values:

true | false

Examples:

true
class·C { ····int·Property ····{ ········[Attr]·get·return·x} ········[Attr]·set·value} ····} }
false
class·C { ····int·Property ····{ ········[Attr]·get·return·x} ········[Attr]·set·value} ····} }

Place simple accessor on single line

Property names:

[resharper_]csharp_place_simple_accessor_on_single_line, [resharper_]csharp_place_simple_blocks_on_single_line, [resharper_]place_simple_accessor_on_single_line, [resharper_]place_simple_blocks_on_single_line

Possible values:

true | false

Examples:

true
class·C { ····int·Property ····{ ········get·return·x} ········set ········{ ············if·(value·==·nullthrow·new·Exception(); ········} ····} }
false
class·C { ····int·Property ····{ ········get ········{ ············return·x; ········} ········set ········{ ············if·(value·==·nullthrow·new·Exception(); ········} ····} }

Place simple method on single line

Property names:

[resharper_]csharp_place_simple_method_on_single_line, [resharper_]csharp_place_simple_blocks_on_single_line, [resharper_]place_simple_method_on_single_line, [resharper_]place_simple_blocks_on_single_line

Possible values:

true | false

Examples:

true
class·C { ····void·Foo()·DoSomethingSimple();·} }
false
class·C { ····void·Foo() ····{ ········DoSomethingSimple(); ····} }

Place simple anonymous method on single line

Property names:

[resharper_]csharp_place_simple_anonymousmethod_on_single_line, [resharper_]csharp_place_simple_blocks_on_single_line, [resharper_]place_simple_anonymousmethod_on_single_line, [resharper_]place_simple_blocks_on_single_line

Possible values:

true | false

Examples:

true
EventHandler·delegate·return};
false
EventHandler·delegate { ····return; };

Place simple array, object and collection on single line

Property names:

[resharper_]csharp_place_simple_initializer_on_single_line, [resharper_]place_simple_initializer_on_single_line

Possible values:

true | false

Examples:

Before formatting After formatting, true
var·result·new·};
var·result·new·{0};
Before formatting After formatting, false
var·result·new·};
var·result·new { ····0 };

Place type attribute on same line

Property names:

[resharper_]csharp_place_type_attribute_on_same_line, [resharper_]place_type_attribute_on_same_line

Possible values:

true | false

Examples:

true
[Attribute]·class·C { }
false
[Attribute] class·C { }

Place method attribute on same line

Property names:

[resharper_]csharp_place_method_attribute_on_same_line, [resharper_]place_method_attribute_on_same_line

Possible values:

true | false

Examples:

true
class·C { ····[Attribute]·void·foo() ····{ ····} }
false
class·C { ····[Attribute] ····void·foo() ····{ ····} }

Place property/indexer/event attribute on same line

Property names:

[resharper_]csharp_place_accessorholder_attribute_on_same_line, [resharper_]place_accessorholder_attribute_on_same_line

Possible values:

true | false

Examples:

true
class·C { ····[Attribute]·int·Property ····{ ········get·return·x} ········set·value} ····} }
false
class·C { ····[Attribute] ····int·Property ····{ ········get·return·x} ········set·value} ····} }

Place singleline accessor attribute on same line

Property names:

[resharper_]csharp_place_simple_accessor_attribute_on_same_line, [resharper_]place_simple_accessor_attribute_on_same_line

Possible values:

true | false

Examples:

true
class·C { ····int·Property ····{ ········[Attribute]·get·return·x} ········[Attribute] ········set ········{ ············value; ············NotifySomething(); ········} ····} }
false
class·C { ····int·Property ····{ ········[Attribute] ········get·return·x} ········[Attribute] ········set ········{ ············value; ············NotifySomething(); ········} ····} }

Place multiline accessor attribute on same line

Property names:

[resharper_]csharp_place_complex_accessor_attribute_on_same_line, [resharper_]place_complex_accessor_attribute_on_same_line

Possible values:

true | false

Examples:

true
class·C { ····int·Property ····{ ········[Attribute]·get·return·x} ········[Attribute]·set ········{ ············value; ············NotifySomething(); ········} ····} }
false
class·C { ····int·Property ····{ ········[Attribute]·get·return·x} ········[Attribute] ········set ········{ ············value; ············NotifySomething(); ········} ····} }

Place field attribute on same line

Property names:

[resharper_]csharp_place_field_attribute_on_same_line, [resharper_]place_field_attribute_on_same_line

Possible values:

true | false

Examples:

true
class·C { ····[Attribute]·int·x; }
false
class·C { ····[Attribute] ····int·x; }

Place constructor initializer on same line

Property names:

[resharper_]csharp_place_constructor_initializer_on_same_line, [resharper_]place_constructor_initializer_on_same_line

Possible values:

true | false

Examples:

true
class·C { ····public·C()·base() ····{ ····} }
false
class·C { ····public·C() ········base() ····{ ····} }

Place type constraints on same line

Property names:

[resharper_]csharp_place_type_constraints_on_same_line, [resharper_]place_type_constraints_on_same_line

Possible values:

true | false

Examples:

true
class·C<Twhere·IEnumerable { }
false
class·C<T> ····where·IEnumerable { }

Allow comment after '{'

Property names:

[resharper_]csharp_allow_comment_after_lbrace, [resharper_]allow_comment_after_lbrace

Possible values:

true | false

Examples:

true
if·(condition) //·comment ····statement; }
false
if·(condition) { ····//·comment ····statement; }
Last modified: 12 October 2017