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

Extensions with constrained generic types are not recommended when invoked on a generic method parameter #72457

Closed
Rekkonnect opened this issue Mar 8, 2024 · 2 comments · Fixed by #72853
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@Rekkonnect
Copy link
Contributor

Versions Used

VS 2022 Version 17.9.2
Roslyn 4.9.0 (a98c90d)

VS 2022 Version 17.10.0 Preview 1
Roslyn 4.10.0 (fa72fa6)

Project info
C# 12.0
.NET 8.0

Steps to Reproduce

  1. Have an extension class
  2. Define a generic extension method where the this parameter is a generic type parameter from the extension method
  3. Assign constraints to the generic type parameter that is the extension
  4. Attempt to invoke the generic extension method on a value satisfying the constraints
  5. Observe the IntelliSense suggestions

A relatively long code snippet is found on SharpLab, showing multiple cases of failing to suggest valid extensions. Try typing the names of the extensions anew to notice the lack of the suggestion.

Expected Behavior

All generic extension methods that have their generic type parameter constraints met are recommended.

Actual Behavior

Only unconstrained generic methods are recommended. When a desired generic extension method is manually typed, it is properly recognized and no error is reported.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 8, 2024
@CyrusNajmabadi CyrusNajmabadi added Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 8, 2024
@CyrusNajmabadi CyrusNajmabadi added this to the Backlog milestone Mar 8, 2024
@Rekkonnect
Copy link
Contributor Author

Can I take this up?

@CyrusNajmabadi
Copy link
Member

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
Status: Completed
3 participants