Back to Devexpress

Collapse Accessors

coderushforroslyn-120375-code-style-assistance-code-formatters-collapse-accessors.md

latest974 B
Original Source

Collapse Accessors

  • Aug 03, 2020

Purpose

Collapses accessors’ code into a single line to make code more compact. However, single-line accessors can decrease readability.

Availability

Available when the caret is on a property name or get / set statement inside the property declaration (both accessors should consist of a single statement).

Usage

  1. Place the caret on a property name or get / set statement.

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

  3. Select Collapse Accessors from the menu.

After executing refactoring, the Code Formatter removes the line breaks and converts property accessors to a single-line form.

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

See Also

Collapse/Expand Getter/Setter