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

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 14 04:59:23 PST 2021


MyDeveloperDay added a comment.

In D115673#3191408 <https://reviews.llvm.org/D115673#3191408>, @curdeius wrote:

> 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)),
>      };

I thought that would be the case but actually I tried a load from the Microsoft docs and most where good, it seems to be the numerical ones that seems to be struggling.


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