Extend the "Use collection expression" suggestion to scenarios requiring the spread operator #75870
Labels
Area-IDE
Feature Request
help wanted
The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone
Summary
Expand the Roslyn analyzers to suggest using
[.. collection]
syntax where applicable. This is a more concise and expressive way to initialize collection from elements in existing collections.Background and Motivation
The IDE currently suggests collection initialization when a spread operator wouldn't be required. The motivation for this feature is the same as the existing suggestions, informing developers of the existence of a more readable syntax. Notably, ReSharper already suggests using collection expressions in these situations. Adding this feature directly to Roslyn would ensure consistency and improve native support for modern C# practices.
Proposed Feature
Before:
After:
Before:
After:
Before:
After:
The text was updated successfully, but these errors were encountered: