-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Champion "pattern-matching with generics" (C# 7.1) #154
Comments
This is a very surprising limitation. It severely limits the usefulness of pattern matching in generic code, making many of the changes I was hoping to make to my code base impossible. |
@axel-habermaier cast the switch expression to |
I think this is also related here (dotnet/roslyn#17746)
Ideally, |
@gafter thanks for the work around but I really would like to have this work. I had the exact same experience as @axel-habermaier and it was very frustrating especially as the error was the direct result of applying a built in Roslyn suggested refactoring inside the implementation of a pattern matching API I had written. I realize it's probably a bug in the analyzer but that really compounded the frustration since the |
@aluanhaddad We discussed this in the LDM, and we believe this is an issue that definitely should be addressed. @gafter's comment was more about what you could do in the meantime to unblock yourself. We'll hopefully get this addressed in a upcoming release of VS (hopefully the next one :)). Note: we've hit this issue in our own code, so we definitely feel your pain and understand why you'd want this fixed :) |
@CyrusNajmabadi Thank you. I'm really glad to hear that this is likely to be resolved soon. That is excellent news! |
Yup! Though note the standard caveats about not being able to guarantee anything, and the future may change blah blah blah. But i'm crossing my fingers that this smoothly slots into the 7.1 release. |
Indeed. Deadlines get missed. If that were a cardinal sin in our industry I probably wouldn't even have a job anymore. |
…ameters. Fixes dotnet#16195 This is a language change for 7.1. See dotnet/csharplang#154. Some tests may fail until dotnet#18756 is integrated.
I have added a proposal for this, and a PR exists for it in the Roslyn repo at dotnet/roslyn#18784. |
…ameters. (#18784) Fixes #16195 This is a language change for 7.1. See dotnet/csharplang#154.
Yes |
Shouldn't it be closed, then? |
There is a remaining workitem to update the language spec to reflect this feature. That's why the issue is kept open. |
Thank you for reply |
The link to the proposal in the description is broken. Should be https://github.com/dotnet/csharplang/blob/master/proposals/csharp-7.1/generics-pattern-match.md |
@reinseth Fixed. Thanks |
See dotnet/roslyn#16195 (comment)
The text was updated successfully, but these errors were encountered: