Skip to content

Fix occurrence of IDE0028 for a c# Dictionary causes compile error CS9215 #75894

@vsfeedback

Description

@vsfeedback

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


[regression] [worked-in:17.12.0]
In 17.13.0 Preview 1.0 visual studio suggests a fix for IDE0028 "Collection initialization can be simplified" for the following dotnet8 code

From:

Dictionary<string, string> a = [];
Dictionary<string, string> b = new(a);

To:

Dictionary<string, string> a = [];
Dictionary<string, string> b = [.. a];

This causes the error CS9215 "Collection expression type 'Dictionary<string, string>' must have an instance or extension method 'Add' that can be called with a single argument"

I checked 17.12.0 and this same code does not create an intellisense message or suggest the erroneous fix in this way.


Original Comments

Feedback Bot on 11/12/2024, 09:10 PM:

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.

Feedback Bot on 11/13/2024, 06:38 AM:

This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions