[PATCH] D115673: [clang-format] C# switch expression formatting differs from normal switch formatting

Marek Kurdej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 13 23:12:22 PST 2021


curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

LGTM. AFAIK (which is very limited when it comes to C#), the cases can have also other expressions, not only ints and _. But that can be left for a different patch.
Example from https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/functional/pattern-matching

  public State PerformOperation(Operation command) =>
     command switch
     {
         Operation.SystemTest => RunDiagnostics(),
         Operation.Start => StartSystem(),
         Operation.Stop => StopSystem(),
         Operation.Reset => ResetToReady(),
         _ => throw new ArgumentException("Invalid enum value for command", nameof(command)),
     };


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115673/new/

https://reviews.llvm.org/D115673



More information about the cfe-commits mailing list