microsoft / microsoft/node-api-dotnet

JSImportAttribute for easier invocation of JS APIs from C#

Offen
#90 0 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@jasongin arbeitet bereits daran.

Seit 12.4.2023.

enhancement marshalling
Vorherrschende Sprache
C#
Sterne
783
Forks
80
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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#.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.