Skip to content

AddOpenCodeFixProvider does not take generics into account #17150

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

Closed
abelbraaksma opened this issue May 15, 2024 · 1 comment
Closed

AddOpenCodeFixProvider does not take generics into account #17150

abelbraaksma opened this issue May 15, 2024 · 1 comment
Labels
Area-LangService-CodeFixes Code fixes associated with diagnostics Bug
Milestone

Comments

@abelbraaksma
Copy link
Contributor

abelbraaksma commented May 15, 2024

If your type name is clearly a generic name, the suggested opens from the AddOpenCodeFixProvider do not include the generic ones.

Repro steps

Type the following code in a file that does not have the collections open:

module Foo =
    let x = dict [ 1, 4] :?> IDictionary<_,_>  // FS0039 type not defined

Expected behavior

The suggestions for the type should either:

a. include only any generic types, as the current type if clearly generic
b. include both generic types and non-generic ones

Actual behavior

Only the non-generic ones are shown in the list of suggestions.

image

Known workarounds

Fix it by hand instead.

Related information

I feel like the reported range for the FS0039 should include the generic part as well (as seen in the screenshot, it isn't, and therefore the code fix provider cannot trivially get enough information). I remember, though, that in a not so far away past, generic types were included in the dropdown, so this may have been a conscious removal. Yet I wonder if we could get it back?

Seen in latest RTM of VS, and seen in VS 17.10.0 Preview 7.0 on Windows 11.

@kerams
Copy link
Contributor

kerams commented May 15, 2024

#16155

@abelbraaksma abelbraaksma closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2024
@abelbraaksma abelbraaksma added Area-LangService-CodeFixes Code fixes associated with diagnostics and removed Needs-Triage labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-LangService-CodeFixes Code fixes associated with diagnostics Bug
Projects
Archived in project
Development

No branches or pull requests

2 participants