Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#502 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp, javascript, typescript
領域
api, backend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
C#
スター
783
フォーク
80
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/node-api-dotnet のほかの issue

microsoft/node-api-dotnet の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。