-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Feature Request - DevToolsClient add strongly typed Events #3666
Comments
I'm wondering if we might be able to simplify our event handling using a pattern similar to
|
This assumes that all event handlers for a specific Currently we support multiple event handlers of different types for the same devToolsClient.Network.RequestWillBeSent += (object sender, RequestWillBeSentEventArgs args) =>
{
};
devToolsClient.RegisterEventHandler("Network.requestWillBeSent", (object sender, DevToolsDomainEventArgsBase args) =>
{
});
devToolsClient.RegisterEventHandler("Network.requestWillBeSent", (object sender, MyRequestWillBeSentEventArgs args) =>
{
});
[DataContract]
private class MyRequestWillBeSentEventArgs : DevToolsDomainEventArgsBase
{
} If we not only group event handlers by (To be honest, I don't know how common it would be to use different types for the same |
Just a view: I came from WebView2, where there are no typed calls or events for DevTools. I have found the typed versions in CEFSharp to be very useful, so my vote would be for the same events typed as you have on the calls. |
That was my original intention, this would greatly simplify our code. Keeping support for multiple types is of course possible, just not clear it's required.
It seems like an edge case that would rarely if ever be used. Long as you can manually subscribe with your own type or use the built in event handler then I think that will be sufficient. We can then look at cleaning up the event handlers on
@ukandrewc If you are using the strongly typed events provided currently e.g. If you are using multiple types for the same event as detailed by @campersau then that will no longer be supported. |
Now it's only possible to register one System.Type per event. - Remove RegisterEventHandler - Add AddEventHandler and RemoveEventHandler - Change constraint from DevToolsDomainEventArgsBase to EventArgs #3666
Save approx 2000 lines of generated code. |
* DevTools Client - Simplify Strongly Typed Event handling Now it's only possible to register one System.Type per event. - Remove RegisterEventHandler - Add AddEventHandler and RemoveEventHandler - Change constraint from DevToolsDomainEventArgsBase to EventArgs #3666 * Changes were based on https://github.com/CefNet/CefNet.DevTools.Protocol Add links to original source files * Reset stream position * AddEventHandler - Use GetOrAdd for Thread safety * AddEventHandler - Fix double event handler registration for first call * RemoveEventHandler - Remove IEventProxy when handler null
#3229 added support for calling
DevTools
methods in a strongly typed fashion.EventArgs
and classes to represent the params.The text was updated successfully, but these errors were encountered: