-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Make Generic EventHandler Contravariant #5665
Comments
this cant work, when raising the event in Foo you pass FooEventArgs. but all handlers you register in if u flip inheritance it can work, remove eventhandler in Foo and derive Foo from |
If you swap EventHandler with ContravariantEventHandler as defined below this works just fine. Events can only be raised in the defining type or nested types. Since Foo only specifies the add and remove event handler operations this is entirely legal.
|
After poking around on StackOverflow I found this question which seems to imply that it was originally made contravariant but there were issues internally related to combining multi-cast delegates. Does anyone know if this is still an issue? |
I believe #4556 is root cause for this restriction. |
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process. This process is part of our issue cleanup automation. |
This issue will now be closed since it had been marked |
Is there any reason the generic EventHandler delegate was not made contravariant? As opposed to creating my own custom EventHandler delegate it would be much better if I could just use the built-in one for my use case listed below.
The text was updated successfully, but these errors were encountered: