Skip to content

Fix explicit WinRT delegate selection for JavaScript and Python - #207

Open
leileizhang (lei9444) wants to merge 2 commits into
mainfrom
lei9444-explicit-delegate-selection
Open

leileizhang (lei9444) wants to merge 2 commits into
mainfrom
lei9444-explicit-delegate-selection

Conversation

@lei9444

@lei9444 leileizhang (lei9444) commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Explicitly selecting ThreadPool,WorkItemHandler classified the delegate as an ordinary runtime class. Its placeholder displaced the correct dependency module: JavaScript rejected normal callbacks with Failed to recover WinGUID, and Python rejected them as non-DynWinRTValue inputs before native invocation.

Fix

Classify non-generic WinRT delegate roots from their metadata kind/base, public WinRT flags, typed IID, and Invoke contract before class fallback. Reuse the existing shared delegate/interface dependency parser for both languages and include standalone delegates in namespace selection. Malformed/non-WinRT/open-generic roots fail explicitly; public-interface and Classic COM routing remain unchanged. The delegate fix does not change runtime, ABI, lifetime, renderer, release, or unrelated projection behavior.

Regression coverage includes delegate-only, combined/reversed roots, automatic dependencies, repeat/incremental selection, namespace roots, ThreadPoolTimer's delegate family, malformed contracts, JS CJS/ESM and declarations, and Python with/without stubs. CLI help and codegen documentation now describe delegate selection.

Separate CI compatibility prerequisite: the additive commit copies only the approved tiny Rust 1.99 fixture-format correction from 49c7e6e2e7042b527f1fee9d6655a8df8f537099: allow a trailing comma in the test-only stub! matcher and format its two existing audio invocations. The one-file delta is byte-identical to that source commit. Both invocation argument lists and the emitted extern "system" function signature/E_NOTIMPL body are unchanged. No functional commit or dependent branch is imported; the original main base is retained.

Verification

  • 33 focused codegen/delegate/snapshot/raw-signature tests pass; strict TypeScript, mypy and Pyright callable consumers include positive and rejection cases. All eight new regressions pass again with the additive prerequisite.
  • Fresh main generator and matched production bindings reproduce both original failures with zero callbacks. Fixed explicitly generated bindings execute and await a real OS ThreadPool callback in JS CJS/ESM and Python on ARM64 and x64 processes under Windows ARM64 emulation. Child processes are timeout-bounded; Python uses RoApartment() and projected_lifetime_scope().
  • Sixteen .js/.d.ts/.py/.pyi comparisons for ThreadPool/WorkItemHandler and ThreadPoolTimer/TimerElapsedHandler are byte-identical to fresh-main automatic dependency output. Existing JS/Python delegate runtime selectors pass; local Rust 1.97/1.98.1 formatting is clean.
  • Full local codegen run: 1,028 passed, one ignored, one existing long-path mypy import failure. The exact-main and fixed generators produce byte-identical diagnostics for that failure at the same original test path (82 relevant stubs identical); both pass in a short-path control. No unrelated projection fix included.

Independent base: de91e9b3889aafdda44098d5ea1b731f9976a3c6. Metadata: Windows SDK 10.0.26100.0, Windows.winmd SHA-256 11191cbcc796e520d47547b3f986be94a48556fe336d4e63334596d9f31a7806. Local native evidence uses Node 24.15.0 and CPython 3.13.15; hosted x64 CI results are separate.

leileizhang (lei9444) and others added 2 commits October 1, 2026 21:59
Classify validated non-generic WinRT delegates before runtime-class fallback and reuse the shared dependency interface parser for JavaScript and Python. Include namespace roots, selection-order/incremental regressions, strict callable consumers, and bounded real ThreadPool callback fixtures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Accept optional trailing commas and format the two existing macro calls required by hosted Rust 1.99. Generated native signatures and behavior are unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Mixed-language test coverage

Workflow status: ✅ Passed

Layer Lines Functions Branches/regions
Rust, including native .pyd/.node 86.95% 82.47% 86.66% regions
Python aggregate 72.34% n/a 39.42% branches
Python runtime 98.17% n/a 94.57% branches
Generated Python WinRT projections 71.07% n/a 33.5% branches
Generated Python WinRT implementations 71.97% n/a 46.3% branches
JavaScript aggregate 21.91% 25.18% 57.61% branches
JavaScript runtime 44.27% 45.76% 78.99% branches
Generated WinRT projections 22.8% 18.7% 54.84% branches
Generated WinRT implementations 45.99% 59.19% 60.97% branches
Generated Classic COM projections 11.88% 23.97% 53.4% branches

View workflow run and download full HTML/LCOV/XML reports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant