Add support for TEventArgs without type constraints #285
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add support for proxy generated clients with event handlers that take args that do not derive from
EventArgs
.History lesson: From .NET 2.0 to 4.0, the
EventHandler<T>
delegate type had a type constraint ofT : EventArgs
, meaning that the second parameter that the event handler takes must derive from `EventArgs. In .NET 4.5, this type constraint was dropped. Apparently they consider this a non-breaking change. But when dealing with code gen and reflection, all bets are off. :)Not realizing this, my event wiring code assumed that deriving from
EventArgs
was a guarantee. As a result, when a user defines an event typed asEventHandler<T>
whereT
does not derive fromEventArgs
, we would fail.This PR fixes it. Supporting
T : class
was as easy as changingEventArgs
toobject
in my event handler. But to supportT : struct
required that I bring in a generic method.Fixes #284