microsoft / microsoft/node-api-dotnet

JSImportAttribute for easier invocation of JS APIs from C#

Open
#90 0 comments 0 reactions 1 assignee View on GitHub

@jasongin is already working on this.

Since Apr 12, 2023.

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

Description

This issue tracks the idea of introducing a new JSImportAttribute type to the library, with associated source-generator support.

When [JSImport] is applied to a C# static partial method, the generated code will load a reference to the JS function (named in an attribute parameter) and marshal the parameters and return value.

Importing entire JS classes could also be supported, with more effort: When [JSImport] is applied to a C# partial class, the generated code will include a constructor that constructs an instance of the JS type (named in an attribute parameter), and implementations of all methods to marshal parameters and return values.

This could even be extended to reading TypeScript type-definitions, eliminating some of the need to declare all of the API surface 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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.