Line up => in switch expression
- Dominant language
- No language data
- Stars
- 1.9k
- Forks
- 173
- Avg merge
- 10d 13h
- Merged PRs (30d)
- 1
Description
Switch expressions (introduced in c# 8) in all the official Microsoft examples line up the '=>' across the lines to make it easier to read:
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/switch-expression
https://devblogs.microsoft.com/dotnet/do-more-with-patterns-in-c-8-0/
```
static State ChangeState(State current, Transition transition, bool hasKey) =>
(current, transition) switch
{
(Opened, Close) => Closed,
(Closed, Open) => Opened,
(Closed, Lock) when hasKey => Locked,
(Locked, Unlock) when hasKey => Closed,
_ => throw new InvalidOperationException($"Invalid transition")
};
```
However dotnet format does not allow this:
```
MyClass.cs(88,29): error WHITESPACE: Fix whitespace formatting. Delete 13 characters. [/MyProject.csproj]
MyClass.cs(89,28): error WHITESPACE: Fix whitespace formatting. Delete 14 characters. [/MyProject.csproj]
MyClass.cs(90,40): error WHITESPACE: Fix whitespace formatting. Delete 2 characters. [/MyProject.csproj]
```
We need a way to configure dotnet format to allow switch expressions to line up.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.