Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#502 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Lĩnh vực
api, backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C#
Star
783
Fork
80
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/node-api-dotnet

Tất cả issue của microsoft/node-api-dotnet

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.