Table of Contents

SA1136: Enum values should be on separate lines

📝 This rule is new for StyleCop Analyzers, and was not present in StyleCop Classic.

Cause

Multiple enum values are placed on the same line of code.

Rule description

A violation of this rule occurs when two or more enum values are placed on the same line of code.

For example, the following code would produce a violation of this rule:

public enum ExampleEnum
{
    FirstValue, SecondValue
}

The following code would not produce any violations:

public enum ExampleEnum
{
    FirstValue,
    SecondValue
}

How to fix violations

To fix a violation of this rule, place each enum value on its own line.

How to suppress violations

#pragma warning disable SA1136 // Enum values should be on separate lines
public enum ExampleEnum
{
    FirstValue, SecondValue
}
#pragma warning restore SA1136 // Enum values should be on separate lines