Skip to content
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

Incorrect documentation of CoreWebView2.AddHostObjectToScript for WinRT #2837

Open
softworkz opened this issue Sep 14, 2023 · 4 comments
Open
Labels
ADO cat: webview2 WebView-related content.

Comments

@softworkz
Copy link

softworkz commented Sep 14, 2023

The documentation for AddHostObjectToScript is incorrect. It's obviously copied from the documentation for the .NET version of WebView2, but for WinRT, the procedures are different (and complicated unfortunately):

https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2?view=webview2-winrt-1.0.2065-prerelease#addhostobjecttoscript

For WinRT, an insane effort is required which involves creating a separate project for the classes that should be exposed and it also requires adding a C++ project (like WinRtAdapter in the code sample), which creates WinRT/COM definitions, which finally need to be wrapped again via methods from ICoreWebView2DispatchAdapter.
(roughly like that)

These procedures are not documented and the current description is wrong for WinRT.


AB#46593196 - Deliverable, auto-created
AB#51566922 - Bug, for triage

@mikehoffms
Copy link
Contributor

Related article:
Call native-side WinRT code from web-side code
https://learn.microsoft.com/microsoft-edge/webview2/how-to/winrt-from-js

@softworkz
Copy link
Author

Related article: Call native-side WinRT code from web-side code learn.microsoft.com/microsoft-edge/webview2/how-to/winrt-from-js

Yes, I know that article - which is providing correct information.

But the part I referenced above is incorrect.

@captainbrosset captainbrosset changed the title [DevTools Docs Feedback] Incorrect documentation of CoreWebView2.AddHostObjectToScript for WinRT Incorrect documentation of CoreWebView2.AddHostObjectToScript for WinRT Sep 18, 2023
@captainbrosset captainbrosset added cat: webview2 WebView-related content. and removed triage-needed labels Sep 18, 2023
@captainbrosset
Copy link
Contributor

Thank you for reporting this. I'm making sure this goes into our backlog.

@mikehoffms
Copy link
Contributor

added 2nd AB# at top, for Bug that's being triaged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADO cat: webview2 WebView-related content.
Projects
None yet
Development

No branches or pull requests

3 participants