Skip to content

Use Collection expressions and Target-typed new - #3167

Open
stefannikolei wants to merge 1 commit into
SixLabors:mainfrom
stefannikolei:sn/collection-expressions
Open

Use Collection expressions and Target-typed new#3167
stefannikolei wants to merge 1 commit into
SixLabors:mainfrom
stefannikolei:sn/collection-expressions

Conversation

@stefannikolei

Copy link
Copy Markdown
Contributor
  1. Collection expressions ([] syntax) replacing new List<T>(), new T[] {}, .ToArray(), etc.
  2. Target-typed new() expressions where appropriate
  3. Using spread elements ([.. collection]) instead of .ToArray() and .Concat().ToArray()
  4. Adding #pragma warning disable/restore CS0649 for intentionally unassigned struct fields

@JimBobSquarePants These were all reported from rider and were fixed automatically. Rider/Resharper finds way more cases than Visual Studio

@stefannikolei
stefannikolei force-pushed the sn/collection-expressions branch from aa6bd3f to 188ff1f Compare August 17, 2026 06:44
1. Collection expressions (`[]` syntax) replacing `new List<T>()`, `new T[] {}`, `.ToArray()`, etc.
2. Target-typed `new()` expressions where appropriate
3. Using spread elements (`[.. collection]`) instead of `.ToArray()` and `.Concat().ToArray()`
4. Adding `#pragma warning disable/restore CS0649` for intentionally unassigned struct fields
@stefannikolei
stefannikolei force-pushed the sn/collection-expressions branch from 188ff1f to eb549bc Compare August 17, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant