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

SA1137 is not raised in C# 12 collection expressions #3904

Open
ar-schraml opened this issue Nov 22, 2024 · 1 comment
Open

SA1137 is not raised in C# 12 collection expressions #3904

ar-schraml opened this issue Nov 22, 2024 · 1 comment

Comments

@ar-schraml
Copy link

The error code SA1137: Elements should have the same indentation is not raised in C# 12 collection expressions.

Example:
image
SA1137 is correctly raised inside an object initialization (example1), but it is missing in collection expressions (example2)

Example code

    private readonly List<string> example1 = new()
    {
        "a",
"b",
                "c",
    };

    private readonly List<string> example2 =
    [
        "a",
"b",
                "c",
    ];

@Mivee
Copy link

Mivee commented Dec 14, 2024

Heyha, I'd like to give it a shot, but since its also my first open source contribution in general I dont know how long it will take.

Mivee added a commit to Mivee/StyleCopAnalyzers that referenced this issue Dec 14, 2024
Collectionexpressions are detected as variable declarations and not as InitializerExpression

- Filter based on the declared variables collectionexpressions out, and then check each element
Mivee added a commit to Mivee/StyleCopAnalyzers that referenced this issue Dec 20, 2024
Collectionexpressions are detected as variable declarations and not as InitializerExpression

- Filter based on the declared variables collectionexpressions out, and then check each element
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants