dotnet / dotnet/sdk

Incorrect list patttern formatting

Open
#45,363 2 comments 5 reactions 0 assignees View on GitHub
Area-Format untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Describe the bug

`dotnet format` removes indentation before list patterns in switch expressions

### To Reproduce

Create a new console project with the following code:

```csharp
Console.WriteLine(args switch
{
[] => "empty",
_ => "not empty"
});
```

Observe the following error:

```console
$ dotnet format --verify-no-changes
/Users/matissehack/Desktop/format/Program.cs(3,1): error WHITESPACE: Fix whitespace formatting. Delete 4 characters. [/Users/matissehack/Desktop/format/format.csproj]
```

### Exceptions (if any)

N/A

### Further technical details

```console
$ dotnet --info
.NET SDK:
Version: 9.0.101
Commit: eedb237549
Workload version: 9.0.100-manifests.4a280210
MSBuild version: 17.12.12+1cce77968

Runtime Environment:
OS Name: Mac OS X
OS Version: 15.1
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/9.0.101/

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
Version: 9.0.0
Architecture: arm64
Commit: 9d5a6a9aa4

.NET SDKs installed:
9.0.101 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 9.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 9.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.