Skip to content

BRO1121: Enum values should be on separate lines

Each enum value starts its own line. Replaces StyleCop SA1136.

Example

Before

public enum Size
{
    Small, Medium,
    Large,
}

After

public enum Size
{
    Small,
    Medium,
    Large,
}

Why

One value per line makes values easy to find, document and reorder, and changes to one value show up as one line in a diff.

How the fix works

A line break goes before each value that shares its line, at the indentation of the first value. An enum written on one line (enum Size { Small, Medium }) gets the same expansion as BRO1509, including the trailing comma BRO1401 wants, so both fixes give the same result.

Not reported

  • A comment between two values.

Compared with StyleCop

Same positions as StyleCop. For an enum on one line StyleCop's fix leaves { Small, and Medium } on the brace lines.