Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect suggestion from IDE0306 when using Stack<T> constructor #76683

Closed
RachelDavids opened this issue Jan 8, 2025 · 0 comments · Fixed by #76684
Closed

Incorrect suggestion from IDE0306 when using Stack<T> constructor #76683

RachelDavids opened this issue Jan 8, 2025 · 0 comments · Fixed by #76684
Assignees
Labels
Area-IDE Bug Feature - IDE0028 Use collection initializer help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@RachelDavids
Copy link

Version Used:
Microsoft Visual Studio Community 2022 (64-bit) - Preview
Version 17.13.0 Preview 2.1

dotnet --info
9.0.200-preview.0.24575.35

Steps to Reproduce:

	T[] a = new T[7];
	// populate
	Stack<T> stack = new Stack<T>(a); // IDE0306 shows for this constructor

Diagnostic Id:

    Error IDE0306: Collection initialization can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0306) (90, 11)

Expected Behavior:

Actual Behavior:

After applying code-fix

Stack<T> stack = [.. a]; // generates CS1061
    Error CS1061: 'Stack<T>' does not contain a definition for 'Add' and no accessible extension method 'Add' accepting a first argument of type 'Stack<T>' could be found (are you missing a using directive or an assembly reference?) (91, 11)
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 8, 2025
@CyrusNajmabadi CyrusNajmabadi self-assigned this Jan 8, 2025
@CyrusNajmabadi CyrusNajmabadi added Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it Feature - IDE0028 Use collection initializer and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 8, 2025
@CyrusNajmabadi CyrusNajmabadi added this to the Backlog milestone Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug Feature - IDE0028 Use collection initializer help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
None yet
3 participants