MicrosoftEdge / MicrosoftEdge/WebView2Feedback
wv2winrt: null as string function parameter value becomes string "null"
@david-risney is already working on this.
Since Jan 23, 2023.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
Description
Consider WebView2 sample app's AddHostObject example - https://github.com/MicrosoftEdge/WebView2Samples/blob/main/SampleApps/webview2_sample_uwp/Pages/AddHostObject.xaml.cs
I updated the code in add_host_object.html to change AddToList function as follows
function AddToList(button) {
let text = button.innerHTML;
bridgeInstance.async().appendToItems(null);
}
But the value that I received in Bridge class AppendToItems is "null" i.e. string containing letters n u l l instead of null
Version
SDK: e.g. 1.0.1518.46
Framework: UWP
OS: Win11
Repro Steps
- Add a break point in the
Bridge.AppendToItemsfunction at the start - Run the sample app in debug mode
- Go to AddHostObject example
- Click on Lion
The expected value of item = null
Actual value of item - "null"
Screenshots

Additional context
Note that if I use a int? instead of string it is able to recognize it as null as expected
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.