Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

How do I export a C# function with a `JSValue` argument?

Abierto
#414 1 comentario 0 reacciones 1 asignado Ver en GitHub

@jasongin ya está trabajando en esto.

Desde el 10/1/2025.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

As per issue title, I'm trying to export a C# class method using TypeExporter.ExportType, but the method is not exported due to the following check, which explicitly disallows JSValue argument types and causes the method to be skipped:

https://github.com/microsoft/node-api-dotnet/blob/a150c53280dbbdebbc51cb84d7384fa3f9313e4b/src/NodeApi.DotNetHost/TypeExporter.cs#L1026-L1028

The method has the following signature:

public async Task<JSValue> sendMessage(JSValue parameters)

The purpose of the C# function is:

  • to call JSON.stringify
  • parse the result with System.Text.Json
  • execute some C# code,
  • serialize the result with System.Text.Json
  • call JSON.parse again to return the result to nodeJS.

(I know, the JSON round-trip could be removed in the future by creating a DTO type, but the JSON data currently has a dynamic structure and needs some work)

Changing the signature to a string and using JSON.stringify in NodeJs is a workaround to make the method appear, but I'd like to pass a JSON object directly.

Lenguaje dominante
C#
Estrellas
783
Forks
80
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/node-api-dotnet

Todos los issues de microsoft/node-api-dotnet

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.