Skip to content

"Collection initialization can be simplified" in code cleanup #82549

@vsfeedback

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


Hi,

When a collection expression can be simplified (ex.: MyObject[] MyObject = new MyObject [] { }), the editor dims "new MyObject [] { }", and "show potential fixes" suggests "Use collection expression". When this command is called manually, "new MyObject [] { }" becomes "[]".

I would like to have it done automatically when i call Code Cleanup, on the active file, but I did not find so far what categories should be activated.
"Fix all warning and errors in EditorConfig" works, but it implies that "dotnet_style_prefer_collection_expression" is explicitly set at "warning" in .editorconfig, while other categories are handled by code cleanup even if they are only "suggestion"

(By the way, there are so many categories and combinations of preferences, that it would help much to be able to navigate to the right ones directly from the suggestion in the context menu).

Regards


Original Comments

Feedback Bot on 1/19/2026, 09:39 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions