Fork me on GitHub
TypeName AddBracesToSwitchSectionsAnalyzer
Check Id CC0073
Category Refactoring
Severity Hidden

Cause

Add curly braces to a switch statement.

Example

int value = 2;
switch (value)
{
    case 1:
      Console.WriteLine(1);
      break;
    case 2:
      Console.WriteLine(2);
      break;
    default:
      Console.WriteLine(0);
      break;
}

Code fix

A code fix will be presented to you that will transform the code.

int value = 2;
switch (value)
{
    case 1:
    {
      Console.WriteLine(1);
      break;
    }
    case 2:
    {
      Console.WriteLine(2);
      break;
    }
    default:
    {
      Console.WriteLine(0);
      break;
    }
}

Code fix

Related rules

TBD

See also

TBD