-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Create WebView2 abstraction for sharing code between ASP.NET Core and .NET MAUI #33125
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pushed a change that should fix the CI failures. It's a bug in the WebView2 packages. |
javiercn
reviewed
Jun 2, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have more high level questions than anything else.
- Are customers supposed to interact with these "wrappers"?
- Can we put a comment like this otherwise?
@javiercn - no & yes. I will add a comment like that on top of the other comments that I have for all the public APIs. |
Comments added. |
javiercn
approved these changes
Jun 4, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Most of this change is quite un-interesting because it's creating an abstraction, implementing it, and then calling it. The most fundamental change is that the WebView2 package no longer references Edge WebView2. Instead, the WPF and WinForms packages reference it in order to implement the abstractions. This allows .NET MAUI's implementation to reference the WinUI WebView2 package, which has different type identities (and some slightly different APIs, too).
What's actually interesting here?
EnsureCoreWebView2Async
no longer takes in an Environment because that's not allowed in WinUI. So the WPF/WinForms implementation store their created Environment and then pass it in. (Not a big deal.)Action AddXYZHandler(my_handler)
where the returnedAction
is a removal callback because otherwise the caller couldn't actually un-hook the event. We don't actually use the removal callbacks right now, but when we do proper disposal, we'll want to unhook event handlers.QueueBlazorStart()
method was added that isn't used in WPF/WinForms, but is used in .NET MAUI WinUI, because it uses autostart='false' and needs to queue Blazor startup. If we choose to always use autostart='false' then we could remove this method and always do it in the common WebView2WebViewManager class.The net result is that
WebView2WebViewManager
changed relatively little, which shows the the abstractions Do The Needful™.Fixes #32770