Skip to content

IDE0028 for collections with constructor arguments #57170

Open

Description

@dellamonica

I would like to use collection expressions when they are plain collections (e.g. [1, 2, 3]) while still keep using the constructor form when passing constructor arguments such as capacity or comparers. Since the same code is used in both scenarios, I either turn it off entirely or live with red squiggles in the code.

It is also not really a short cut when we are initializing an empty container:

HashSet<MyType> set = [with(myTypeComparer)];

versus

HashSet<MyType> set = new(myTypeComparer);

Activity

  1. added
    untriaged
    on Nov 17, 2026
  2. locked and limited conversation to collaborators on Nov 17, 2026
  3. unlocked this conversation on Nov 17, 2026
  4. added
    needs team triage
    and removed
    untriaged
    on Nov 17, 2026
  5. github-actions commented on Nov 17, 2026

    @github-actions
    Contributor

    🎯 Agentic Issue Triage

    Triage Assessment:

    • 🏷️ Labels: Area-Roslyn enhancement needs team triage Requires a full team discussion
    • 💻 Assignment: none | @dotnet/dotnet-cli
    • 🟨 Confidence: medium - IDE0028 is a Roslyn IDE analyzer, but CODEOWNERS has no matching Area-Roslyn section.

    ➡️ Summary: Requests IDE0028 not flag collection initializations that need constructor arguments such as capacity or comparers. Likely belongs with the Roslyn IDE analyzer owners; team should confirm routing.

    Generated by 🏷️ Issue Triage for #57170 · copilot · auto (Claude Sonnet 5.5) · ~16 AIC · ⌖ ~2 AIC · ⊞ 15.5K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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