Skip to content

The pattern book

Wrapping

max_line_length = 160

Sets the target line width used by auto layout preferences.

  • Values: positive integer off
  • Default: 160
  • Applies to: File representation or shared layout settings.
  • Guarantee: The configured value is applied by its owning formatter stage.
  • Shown with: dress_arguments_layout = auto
Input
Call(firstArgument, secondArgument, thirdArgument);

Code unchanged.

dress_arguments_layout = auto

Controls Arguments. Only whitespace owned by syntax wrapping changes. Auto puts each item in a multiline list on its own line and keeps fitting single-line lists compact.

  • Values: always_single auto always_multi
  • Default: auto
  • Applies to: Arguments.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
Call(firstArgument, secondArgument, thirdArgument);

Code unchanged.

dress_parameters_layout = auto

Controls Parameters. Only whitespace owned by syntax wrapping changes. Auto puts each item in a multiline list on its own line and keeps fitting single-line lists compact.

  • Values: always_single auto always_multi
  • Default: auto
  • Applies to: Parameters.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
class Example { void Run(int first, int second, int third) { } }

Code unchanged.

dress_type_arguments_layout = auto

Controls TypeArguments. Only whitespace owned by syntax wrapping changes. The closing bracket stays attached to the last type argument when the list wraps. Auto keeps the first argument on the opening line when the text before the bracket is no wider than the continuation indent, since breaking there would gain no room.

  • Values: always_single auto always_multi
  • Default: auto
  • Applies to: TypeArguments.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
class Example { Dictionary<string, List<int>> Values { get; set; } }

Code unchanged.

dress_collection_expressions_layout = auto

Controls CollectionExpressions. Only whitespace owned by syntax wrapping changes. Auto puts each item in a multiline list on its own line and keeps fitting single-line lists compact.

  • Values: always_single auto always_multi
  • Default: auto
  • Applies to: CollectionExpressions.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
int[] values = [1, 2, 3];

Code unchanged.

dress_base_type_lists_layout = auto

Controls BaseTypeLists. Only whitespace owned by syntax wrapping changes.

  • Values: always_single auto always_multi
  • Default: auto
  • Applies to: BaseTypeLists.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
class Example : Base, IFirst, ISecond { }

Code unchanged.

dress_constraint_clauses_layout = auto

Controls ConstraintClauses. Only whitespace owned by syntax wrapping changes.

  • Values: always_single auto always_multi
  • Default: auto
  • Applies to: ConstraintClauses.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
class Example<T, U> where T : class where U : new() { }

Code unchanged.

dress_attributes_layout = auto

Controls Attributes. Only whitespace owned by syntax wrapping changes. Square brackets stay attached to the first and last attributes when the list wraps.

  • Values: always_single auto always_multi
  • Default: auto
  • Applies to: Attributes.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
[First, Second, Third] class Example { }

Code unchanged.

dress_arguments_closing_delimiter_position = after_last_item

Places a multiline list’s closing delimiter after the last item or on its own line, aligned with the opening line. Single-line lists are unchanged. Comments retain required line breaks.

  • Values: after_last_item own_line
  • Default: after_last_item
  • Applies to: The closing boundary of multiline Arguments.
  • Guarantee: Single-line lists and item layout are unchanged.
Input
Call(
first,
second);

Code unchanged.

dress_parameters_closing_delimiter_position = own_line

Places a multiline list’s closing delimiter after the last item or on its own line, aligned with the opening line. Single-line lists are unchanged. Comments retain required line breaks.

  • Values: after_last_item own_line
  • Default: own_line
  • Applies to: The closing boundary of multiline Parameters.
  • Guarantee: Single-line lists and item layout are unchanged.
Input
class Example(
int value)
{
}
class Example(
int value)
int value
)
{
}

Object initializer closing delimiter position

Section titled “Object initializer closing delimiter position”
dress_object_initializer_closing_delimiter_position = unset

Places a multiline list’s closing delimiter after the last item or on its own line, aligned with the opening line. Single-line lists are unchanged. Comments retain required line breaks.

  • Values: after_last_item own_line
  • Default: unset (the rule makes no change unless you set it)
  • Applies to: The closing boundary of multiline ObjectInitializers.
  • Guarantee: Single-line lists and item layout are unchanged.
Input
var value = new Example
{
First = 1
};
var value = new Example
{
First = 1
};
First = 1 };

Collection initializer closing delimiter position

Section titled “Collection initializer closing delimiter position”
dress_collection_initializer_closing_delimiter_position = unset

Places a multiline list’s closing delimiter after the last item or on its own line, aligned with the opening line. Single-line lists are unchanged. Comments retain required line breaks.

  • Values: after_last_item own_line
  • Default: unset (the rule makes no change unless you set it)
  • Applies to: The closing boundary of multiline CollectionInitializers.
  • Guarantee: Single-line lists and item layout are unchanged.
Input
var values = new List<int>
{
1, 2
};
var values = new List<int>
{
1, 2
};
1, 2 };

Array initializer closing delimiter position

Section titled “Array initializer closing delimiter position”
dress_array_initializer_closing_delimiter_position = unset

Places a multiline list’s closing delimiter after the last item or on its own line, aligned with the opening line. Single-line lists are unchanged. Comments retain required line breaks.

  • Values: after_last_item own_line
  • Default: unset (the rule makes no change unless you set it)
  • Applies to: The closing boundary of multiline ArrayInitializers.
  • Guarantee: Single-line lists and item layout are unchanged.
Input
var values = new[]
{
1, 2
};
var values = new[]
{
1, 2
};
1, 2 };

With initializer closing delimiter position

Section titled “With initializer closing delimiter position”
dress_with_initializer_closing_delimiter_position = unset

Places a multiline list’s closing delimiter after the last item or on its own line, aligned with the opening line. Single-line lists are unchanged. Comments retain required line breaks.

  • Values: after_last_item own_line
  • Default: unset (the rule makes no change unless you set it)
  • Applies to: The closing boundary of multiline WithInitializers.
  • Guarantee: Single-line lists and item layout are unchanged.
Input
var value = original with
{
First = 1
};
var value = original with
{
First = 1
};
First = 1 };

Collection expression closing delimiter position

Section titled “Collection expression closing delimiter position”
dress_collection_expression_closing_delimiter_position = unset

Places a multiline list’s closing delimiter after the last item or on its own line, aligned with the opening line. Single-line lists are unchanged. Comments retain required line breaks.

  • Values: after_last_item own_line
  • Default: unset (the rule makes no change unless you set it)
  • Applies to: The closing boundary of multiline CollectionExpressions.
  • Guarantee: Single-line lists and item layout are unchanged.
Input
int[] values = [
1, 2
];
int[] values = [
1, 2
];
1, 2];
dress_object_initializer_layout = auto

Controls ObjectInitializers. Only whitespace owned by syntax wrapping changes.

  • Values: compact auto expanded
  • Default: auto
  • Applies to: ObjectInitializers.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
var value = new Example { First = 1, Second = 2 };

Code unchanged.

dress_collection_initializer_layout = auto

Controls CollectionInitializers. Only whitespace owned by syntax wrapping changes. The { key, value } elements of the initializer are laid out the same way, with their braces spaced like its own.

  • Values: compact auto expanded
  • Default: auto
  • Applies to: CollectionInitializers.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
var values = new List<int> { 1, 2, 3 };

Code unchanged.

dress_array_initializer_layout = auto

Controls ArrayInitializers. Only whitespace owned by syntax wrapping changes.

  • Values: compact auto expanded
  • Default: auto
  • Applies to: ArrayInitializers.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
var values = new[] { 1, 2, 3 };

Code unchanged.

dress_with_initializer_layout = auto

Controls WithInitializers. Only whitespace owned by syntax wrapping changes.

  • Values: compact auto expanded
  • Default: auto
  • Applies to: WithInitializers.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
var value = original with { First = 1, Second = 2 };

Code unchanged.

dress_member_access_chains_layout = auto

Controls MemberAccessChains. Only whitespace owned by syntax wrapping changes. A wrapped chain keeps its first call with a receiver no wider than the continuation indent, since breaking there would gain no room.

  • Values: always_single auto always_multi
  • Default: auto
  • Applies to: MemberAccessChains.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
var value = source.Where(predicate).Select(selector).ToList();

Code unchanged.

dress_binary_expressions_layout = auto

Controls BinaryExpressions. Only whitespace owned by syntax wrapping changes.

  • Values: always_single auto always_multi
  • Default: auto
  • Applies to: BinaryExpressions.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
var value = first + second + third;

Code unchanged.

dress_binary_expression_indentation = precedence

Controls whether wrapped higher-precedence binary groups align with the outer expression or indent one additional level per precedence group. Does not introduce wrapping.

  • Values: flat precedence
  • Default: precedence
  • Applies to: Wrapped binary expression indentation.
  • Guarantee: Only whitespace changes.
Input
var result = first
|| second
&& third;

Code unchanged.

dress_conditional_expressions_layout = auto

Controls ConditionalExpressions. Only whitespace owned by syntax wrapping changes. Wrapped branches indent one level beyond the deepest formatted line of a multiline condition.

  • Values: always_single auto always_multi
  • Default: auto
  • Applies to: ConditionalExpressions.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
var value = condition ? first : second;

Code unchanged.

dress_nested_conditional_style = decision_ladder

Shapes wrapped nested ternaries. Decision ladders flatten false-branch chains; multiline conditions or branches fall back to staircase. Does not force single-line expressions to wrap.

  • Values: flat staircase decision_ladder
  • Default: decision_ladder
  • Applies to: Nested conditional expression whitespace.
  • Guarantee: Only whitespace changes.
Input
var result = first
? one
: second
? two
: three;
var result = first
? one
: second
? two
: three;
var result = first ? one
: second ? two
: three;
dotnet_style_operator_placement_when_wrapping = beginning_of_line

Places wrapped binary and ternary operators at the beginning or end of the line. Does not introduce wrapping in single-line expressions. Commented operator boundaries are preserved.

  • Values: beginning_of_line end_of_line
  • Default: beginning_of_line
  • Applies to: Binary and conditional operator whitespace.
  • Guarantee: Only whitespace changes.
Input
var result = first
+ second
+ third;

Code unchanged.

dress_query_clauses_layout = auto

Controls QueryClauses. Only whitespace owned by syntax wrapping changes.

  • Values: always_single auto always_multi
  • Default: auto
  • Applies to: QueryClauses.
  • Guarantee: Only whitespace owned by syntax wrapping changes.
Input
var result = from item in items where item.Active select item.Name;

Code unchanged.