MicrosoftEdge / MicrosoftEdge/WebView2Feedback

Does hostobject support array from JavaScript

Open
#1,440 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

My code in C#

[ComVisible(true)]
public class JavaScriptBridge
{
	public int Sum(int[] items)
	{
		return items.Sum();
	}
}

My Coe in JavaScript:

alert(await bridge.Sum([3, 5, 8]));

But it didn't work.
image

I understand that I can work around this issue by using JSON.stringify() to convert an array in JavaScript to a plain string, and pass it to JavaScriptBridge. I just want to know whether there is a more graceful approach?
Thanks.

AB#34069027

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the C# JavaScriptBridge.Sum(int[]) example and the JavaScript bridge.Sum([3, 5, 8]) call shown in the issue. Compare the observed failure with WebView2 host-object interop behavior and determine whether arrays are supported; done means confirming supported marshaling or documenting a graceful supported approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, javascript
Domain
api, desktop
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.