WebView2Feedback icon indicating copy to clipboard operation
WebView2Feedback copied to clipboard

wv2winrt: null as string function parameter value becomes string "null"

Open Take-A-Byte opened this issue 2 years ago • 1 comments

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

  1. Add a break point in the Bridge.AppendToItems function at the start
  2. Run the sample app in debug mode
  3. Go to AddHostObject example
  4. Click on Lion

The expected value of item = null Actual value of item - "null"

Screenshots image

Additional context Note that if I use a int? instead of string it is able to recognize it as null as expected

AB#43066540

Take-A-Byte avatar Jan 20 '23 08:01 Take-A-Byte

Thanks for the easy steps to reproduce the bug via the sample app! This is a good bug, thanks for reporting. I've opened an issue and we will look into this. Thanks.

david-risney avatar Jan 23 '23 17:01 david-risney