Skip to content

SA1513 triggered on object initializer inside collection expression #3720

@jnyrup

Description

@jnyrup

Changing an array initializer containing an object initializer to using collection expression triggers SA1513.
Using StyleCopAnalyzer 1.2.0-beta.507

public class MyClass
{
    public int Value { get; set; }

    public static MyClass[] Foo() => new[]
    {
        new MyClass
        {
            Value = 42
        }
    };

    public static MyClass[] Bar() =>
    [
        new MyClass
        {
            Value = 42
        } // <-- triggers SA1513
    ];
}

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions