Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#414 1 comentário 0 reações 1 responsável Ver no GitHub

@jasongin já está trabalhando nisso.

Desde 10/1/2025.

Avaliação

Esta issue ainda não foi avaliada.

Descrição

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.

Linguagem predominante
C#
Estrelas
783
Forks
80
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de microsoft/node-api-dotnet

Todas as issues de microsoft/node-api-dotnet

Issues semelhantes

Mais issues de C#

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.