Back to Devexpress

Collapse/Expand Property

coderushforroslyn-115368-code-style-assistance-code-formatters-collapse-expand-property.md

latest1.1 KB
Original Source

Collapse/Expand Property

  • Aug 03, 2020

Purpose

Collapses the property declaration onto a single line and vice versa. Single-line properties make your code more compact. On the other hand, they can decrease code readability.

Availability

Available when the caret is on the property variable name, provided that all property accessors consist of a single statement.

Usage

  1. Place the caret on a property variable name.

  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.

  3. Select Collapse Property from the menu ( Expand Property - if you are expanding the property).

After execution, the Code Formatter removes the line breaks, and converts the property to a single-line form or expands it to a multiple-line form.

csharp
public int A { get { return a; } set { a = value; } }

See Also

Collapse/Expand Getter/Setter

Collapse/Expand Method