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

IDisposable: typings say `dispose()`, dynamic binding exposes `Dispose()`

Aberta
#502 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
82/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
csharp, javascript, typescript
Domínio
api, backend

Direção de pesquisa

Start with the cited generator code in src/NodeApi.Generator/TypeDefinitionsGenerator.cs around lines 1217-1221 and the dynamic exporter in src/NodeApi.DotNetHost/TypeExporter.cs around lines 790-797. Reproduce the issue with the provided net472 dynamic-binding example, then verify that generated typings and runtime method names agree for IDisposable; done means calling the typed method no longer fails.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

With dynamic binding (require("node-api-dotnet/net472") then dotnet.load("MyLib.dll")), a class that implements IDisposable gets dispose(): void in the generated .d.ts, but the object at runtime has Dispose and no dispose. Calling the typed name throws TypeError: x.dispose is not a function. TypeScript accepts the call, and a test mock written from the .d.ts passes, so the mismatch only surfaces in production.

Reproduced with node-api-dotnet 0.9.27 and a net472 host:

const t = dotnet.MyLib.Thing.Create();
Object.getOwnPropertyNames(Object.getPrototypeOf(t));
// [..., "Dispose", "Equals", "GetHashCode", "GetType", "ToString", ...]
typeof t.dispose; // "undefined"

The generator renames the method to match the JS convention: https://github.com/microsoft/node-api-dotnet/blob/958b8c3c04dff5414781a88f069062c6528f7427/src/NodeApi.Generator/TypeDefinitionsGenerator.cs#L1217-L1221

The dynamic exporter registers methods under the .NET name with no equivalent rename: https://github.com/microsoft/node-api-dotnet/blob/958b8c3c04dff5414781a88f069062c6528f7427/src/NodeApi.DotNetHost/TypeExporter.cs#L790-L797

Either name is fine, but the two paths should agree.

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.