Skip to content

Commit 83b3b67

Browse files
authored
Update CoreWebView2.CreateFromCOMObject.md
Updates from API review feedback
1 parent 6fb51a0 commit 83b3b67

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

specs/CoreWebView2.CreateFromCOMObject.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
CoreWebView2.CreateFromComObject
1+
CoreWebView2.CreateFromComICoreWebView2
22
===
33

44
# Background
5-
The new [Unity WebView2](https://learn.microsoft.com/en-us/windows/mixed-reality/develop/
6-
advanced-concepts/webview2-unity-plugin) control creates and uses C++ COM to create and manage the
5+
The new [Unity WebView2](https://learn.microsoft.com/windows/mixed-reality/develop/advanced-concepts/webview2-unity-plugin)
6+
control creates and uses C++ COM to create and manage the
77
ICoreWebView2* objects. However, Unity developers are often interacting with the Unity WebView2
88
control using C#/.NET. The Unity WebView2 control doesn't expose the CoreWebView2 directly to devs
99
using the Unity WebView2 control, so when devs want to call an API on CoreWebView2, they
1010
have to rely on that API being exposed on the Unity WebView2 control, which then internally calls
1111
into CoreWebView2. This is in contrast to our other controls (like WPF WebView2 and Winforms
12-
WebView2 controls) which directly give access to their [CoreWebView2 object]
13-
(https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.winforms.webview2.
14-
corewebview2?view=webview2-dotnet-1.0.2088.41), allowing devs to call any API that exists or gets
12+
WebView2 controls) which directly give access to their [CoreWebView2 object](https://learn.microsoft.com/dotnet/api/microsoft.web.webview2.winforms.webview2.corewebview2?view=webview2-dotnet-1.0.2088.41),
13+
allowing devs to call any API that exists or gets
1514
added to the CoreWebView2/ICoreWebView2_*. The Unity WebView2 control can't do this today,
1615
as they are unable to create a CoreWebView2 object that wraps an already existing COM object.
1716
To help implement this for Unity, we are adding a new static factory function on CoreWebView2 .NET
1817
class that will allow it to wrap an existing ICoreWebView2 COM object, instead of creating a new
19-
one underlying ICoreWebView2.
18+
one.
2019

2120
# Examples
22-
## CoreWebView2.CreateFromComObject
21+
## CoreWebView2.CreateFromComICoreWebView2
2322
```c#
2423
public class MyWebView2Control
2524
{
@@ -39,7 +38,7 @@ public class MyWebView2Control
3938
{
4039
IntPtr comPtr = WebViewNative.GetNativePointer(InstanceId);
4140

42-
_myCoreWebView2 = CoreWebView2.CreateFromComObject(comPtr);
41+
_myCoreWebView2 = CoreWebView2.CreateFromComICoreWebView2(comPtr);
4342
}
4443
return _myCoreWebView2;
4544
}
@@ -64,15 +63,15 @@ namespace Microsoft.Web.WebView2.Core
6463
/// <returns>Returns a .NET CoreWebView2 object that wraps the COM object.</returns>
6564
/// <exception cref="ArgumentNullException">Thrown when the provided COM pointer is null.</exception>
6665
/// <exception cref="InvalidComObjectException">Thrown when the value is not an ICoreWebView2 COM object and cannot be wrapped.</exception>
67-
public static CoreWebView2 CreateFromComObject(IntPtr value);
66+
public static CoreWebView2 CreateFromComICoreWebView2(IntPtr value);
6867
}
6968
}
7069
```
7170

7271
# Appendix
73-
We have a couple of other options to accomplish this, including moving the "CreateFromComOBject" function to the
72+
We have a couple of other options to accomplish this, including moving the "CreateFromComICoreWebView2" function to the
7473
CoreWebView2Controller class instead. CoreWebView2Controller could then be used to get the CoreWebView2 through
75-
it's CoreWebView2 property which already exists. Or we could expose a new constructor on CoreWebView2/CoreWebView2Controller,
74+
its CoreWebView2 property which already exists. Or we could expose a new constructor on CoreWebView2/CoreWebView2Controller,
7675
instead of a factory method.
7776

7877
We decided on using the CoreWebView2 due to it being the class most likely to be exposed and used

0 commit comments

Comments
 (0)