Skip to content

Fix generated COM identifiers and aggregate target keys - #150

Merged
leileizhang (lei9444) merged 1 commit into
mainfrom
lei9444-com-codegen-fixes
Sep 11, 2026
Merged

leileizhang (lei9444) merged 1 commit into
mainfrom
lei9444-com-codegen-fixes

Conversation

@lei9444

Copy link
Copy Markdown
Contributor

Summary

Fix two independent import blockers reproduced by generating Windows.Win32.UI.Accessibility.IUIAutomation:

  • Generated unsafe parameters such as var produced rectToVariant(rc, var) and a JavaScript syntax error. Share reserved/restricted binding-name escaping with the existing COM JavaScript naming helper. Preserve unsafe parameter casing/Hungarian prefixes, valid contextual names, and existing method spellings. Reject transformed parameter collisions and clashes with generated bindings explicitly, with consistent JavaScript arguments and declarations.
  • Raw aggregate descriptors used the census key i686, but the strict runtime schema accepts x86, x64, and arm64. Translate only descriptor root keys; preserve census/support-report keys and native layouts. Eager POINT registration can now succeed when the generated module loads.

Add a real-metadata regression to the existing generated-unsafe E2E suite: Node syntax checking, independent CommonJS and ESM import/registration, runtime by-value descriptor validation (including rejection of an invalid i686 key), and a TypeScript consumer. Unit regressions cover restricted names, sanitization/collisions, generated locals, and pointer-width-sensitive struct/union descriptors for all three targets.

Boundaries

Based directly on main at e7469c840e6f68310083b23520c6b681601eb276; this is an independent PR, not a stack. No runtime/native ABI, WinRT, npm root API, contract registry migration, or flat Win32 functionality changes. No new safe UIA support or unsafe bypass.

Validation

Windows ARM64, Node v24.15.0; DYNWINRT_WIN32_WINMD points to Microsoft.Windows.SDK.Win32Metadata 71.0.14-preview, SHA256 B64EE4818A7ED9F9D135038D58C51BD08369184D4D5ED428F20E9DE55DF8121D.

Before the fix, reproduced both the Unexpected token 'var' syntax failure and the unchanged runtime's Raw by-value root descriptor contains unknown key i686 failure using the actual generated POINT descriptor. The new E2E regression also failed on baseline generation.

Passed:

  • cargo test -p dynwinrt-codegen --lib -- codegen::com::generated_unsafe::tests codegen::com::javascript::naming::tests codegen::com::capability::tests::raw_aggregate_descriptors_use_runtime_architectures_without_renaming_census_targets — 22 passed, including the exact pinned Stage 2 coverage baseline.
  • cargo test -p dynwinrt-codegen --lib --test win32_com_test -- codegen::com::javascript:: snapshot_ safe_incomplete_interface_generates_an_isolated_unsafe_companion generated_unsafe_preserves_direct_void_pointer_returns — 89 unit + 4 integration tests passed, including existing COM snapshots.
  • cargo test -p dynwinrt-codegen --test snapshot_test — 6 passed, unchanged WinRT JS/Python output.
  • From bindings\js: npm run test:generated-unsafe -- __test__\raw-phase1.spec.ts — 7 passed with the repository-standard native build, generated declarations, and raw-runtime integration.
  • Final targeted parameter/import reruns, changed-file Rust formatting, oxlint, and git diff --check passed.

Limitations: live execution was ARM64 only; x86/x64 descriptor keys, sizes, alignments, and offsets are covered by generation tests, not live x86/x64 calls. The UIA regression performs no activation or native UIA method invocation, keyboard/mouse injection, Electron build, or UI automation.

Share strict JavaScript binding-name escaping without changing unsafe parameter or method naming conventions. Reject transformed parameter and generated-binding collisions before emitting a companion. Serialize raw aggregate layouts with x86/x64/arm64 runtime keys while preserving census vocabulary and ABI layouts. Cover real IUIAutomation syntax, CJS/ESM registration, raw schema validation, and declarations without native UIA calls.

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

Copy link
Copy Markdown

Mixed-language test coverage

Workflow status: ✅ Passed

Layer Lines Functions Branches/regions
Rust, including native .pyd/.node 85.48% 80.81% 85.14% regions
Python aggregate 71.06% n/a 37.9% branches
Python runtime 99.12% n/a 97.37% branches
Generated Python WinRT projections 70.05% n/a 27.07% branches
Generated Python WinRT implementations 72.29% n/a 47.04% branches
JavaScript aggregate 21.98% 25.07% 57.34% branches
JavaScript runtime 38.26% 57.89% 71.01% branches
Generated WinRT projections 22.97% 18.71% 54.94% branches
Generated WinRT implementations 48.66% 59.76% 61.14% branches
Generated Classic COM projections 11.92% 23.97% 54.2% branches

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

@lei9444
leileizhang (lei9444) merged commit 73c25db into main Sep 11, 2026
24 checks passed
@lei9444
leileizhang (lei9444) deleted the lei9444-com-codegen-fixes branch September 11, 2026 07:42
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.

2 participants