microsoft / microsoft/node-api-dotnet

Calling ambiguous overloaded methods

Open
#466 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
783
Forks
80
PR merge metrics
No merged PRs in 30d

Description

Hi,

In NET library that I am using, I have two overloaded methods: x(guid) and x(string).
When calling x('aaa') from JavaScript, marshaller can't decide which method to call which results in TypeError: Multiple overloads were found for the supplied argument types.

I have tried creating both System.String and System.Guid objects in JavaScript and passing it to x, however this results in TypeError: A string was expected: Error in GetValueStringUtf16 at D:\a\_work\1\s\src\NodeApi\JSValue.cs:521

Is there any other way to overcome this in pure JavaScript without resorting to creating some proxy method in C#?

Contributor guide

Open the contributing guide

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 by reproducing the overloaded x(guid) and x(string) call from JavaScript, then inspect NodeApi/JSValue.cs around line 521 and the marshalling path that reports the overload error. Done means establishing whether pure JavaScript can select the intended overload and documenting or implementing a working path without a C# proxy.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, javascript, node.js
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.