Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List pattern is not correctly formatted in the first case of a switch expression #72196

Open
meziantou opened this issue Feb 21, 2024 · 1 comment · May be fixed by #72269 or #75953
Open

List pattern is not correctly formatted in the first case of a switch expression #72196

meziantou opened this issue Feb 21, 2024 · 1 comment · May be fixed by #72269 or #75953
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@meziantou
Copy link
Contributor

Version Used: '4.10.0-1.24081.13 (fa72fa6)' - Visual Studio 17.10.0 Preview 1.0

Language version: 12.0

Steps to Reproduce:

Format the following document in Visual Studio:

_ = Array.Empty<string>() switch
{
    [] => 0,
    _ => 1,
};

The list pattern is push to the left:

_ = Array.Empty<string>() switch
{
[] => 0,
    _ => 1,
};

It seems specific to the list pattern. Other patterns are correctly aligned.

Expected Behavior:

The list pattern stays at the same location.

Actual Behavior:

The list pattern is pushed to the left

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 21, 2024
@SamuelBittmann
Copy link

We have the same issue since .NET SDK 8.0.200. IDE0055 is reported in this case. One additional observation that I have made: No issue is reported when the list of patterns does not start with a list expression, e.g.:

// For this code no warning is reported
var result2 = new int[] { 1, 2 } switch
{
    { Length: 0 } => "empty",
    [1] => "one",
    _ => "unknown"
};

Full repro: https://github.com/SamuelBittmann/ide0055_bug_repro

@CyrusNajmabadi CyrusNajmabadi added Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it Area-IDE and removed Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 21, 2024
@CyrusNajmabadi CyrusNajmabadi added this to the Backlog milestone Feb 21, 2024
victor-pogor added a commit to victor-pogor/roslyn that referenced this issue Feb 25, 2024
victor-pogor added a commit to victor-pogor/roslyn that referenced this issue Feb 26, 2024
@github-project-automation github-project-automation bot moved this to InQueue in Small Fixes Aug 28, 2024
obonn1 pushed a commit to obonn1/roslyn that referenced this issue Nov 18, 2024
@obonn1 obonn1 linked a pull request Nov 18, 2024 that will close this issue
obonn1 pushed a commit to obonn1/roslyn that referenced this issue Nov 20, 2024
obonn1 pushed a commit to obonn1/roslyn that referenced this issue Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
Status: InQueue
3 participants