Skip to content

Count JS bindings recursively in the electron sample test - #800

Merged
Jaylyn Barbee (Jaylyn-Barbee) merged 1 commit into
mainfrom
jay/fix-electron-bindings-recurse
Sep 1, 2026
Merged

Jaylyn Barbee (Jaylyn-Barbee) merged 1 commit into
mainfrom
jay/fix-electron-bindings-recurse

Conversation

@Jaylyn-Barbee

Copy link
Copy Markdown
Contributor

What is wrong

Every open PR started failing the electron sample test today, regardless of its contents.

@microsoft/dynwinrt-codegen@0.1.0-preview.20 was published 2026-09-01T14:42:36Z and changed the generated-bindings layout from flat to namespace-nested (windows/foundation/...).

The assertion in samples/electron/test.Tests.ps1 counted .js files non-recursively, so it stopped seeing the generated bindings and only counted the 3 root scaffolding files.

Show me

Expected the actual value to be greater than 50, because Default jsBindings
(full WinAppSDK) should generate many JS files, but got 3.
at $jsCount | Should -BeGreaterThan 50, samples\electron\test.Tests.ps1:136

Reproduced locally by running both codegen builds against the same metadata (C:\Windows\System32\WinMetadata, --namespace Windows.Foundation):

codegen top-level .js recursive .js subdirs
0.1.0-preview.19 26 26 0
0.1.0-preview.20 3 26 1 (windows/foundation/)

The 3 survivors are index.js, index.proxy.js, and lifetime.js (index.mjs does not match the *.js filter). Those root files are emitted regardless of how much is generated, so the top-level count is now a constant — it no longer scales with output at all.

Why it matters

Nothing is actually broken. The generated file set is unchanged (26 recursive in both versions), and every downstream test passed: winmds.lock.json, #winapp/bindings resolution via Node package imports, generate-bindings regeneration, and cross-language drift detection. This is a stale test assertion, not a functional regression.

But it blocked everyone: 7 runs across 5 branches and 4 authors. The cleanest evidence that no PR caused it — azchohfi-uiautomation-nuget-package was green at 06:38Z and red at 17:46Z on the same branch, straddling the publish. Every run before 14:42Z passed, back to Aug 27; every run after it failed.

The fix

Add -Recurse. The generated file set did not change, only its location, so the recursive count today equals the old flat count and the > 50 threshold keeps exactly the meaning it had. It is layout-agnostic, so it holds whether codegen nests further or reverts to flat, and it still catches the "0 files generated" regression the assertion was written for (scaffolding-only output is 3, far below 50).

Follow-up, not addressed here

ensureCodegenInstalledForInit (src/winapp-npm/src/jsbindings/cli-hooks.ts:507) installs this package at latest, unpinned by design:

latest (not pinned) on purpose: codegen ships independently of winappcli and the ABI-lockstep step then queries its runtime-dependency capability for the matching runtime pin.

Two consequences worth discussing separately:

  1. Any codegen publish can red-wall every branch at once, as it did here. There is no scheduled canary — test-samples.yml runs only on pull_request and workflow_dispatch, so the first signal is always a contributor's PR going red.
  2. It bypasses our 7-day cooldown. .github/dependabot.yml sets cooldown: default-days: 7, but that only governs manifests dependabot tracks (/src/winapp-npm). This package is in no such manifest — our own init code installs it into the user's project — so the cooldown structurally cannot apply. CI consumed preview.20 roughly 4 hours after publish, and the same code path runs on a user's machine.

I have not changed that behavior here, to keep this PR limited to unblocking CI.

dynwinrt-codegen 0.1.0-preview.20 (published 2026-09-01) moved generated
bindings from a flat layout into namespace subdirectories, so the
non-recursive Get-ChildItem only saw the 3 root scaffolding files
(index.js, index.proxy.js, lifetime.js) and failed the "> 50" assertion.

The generated file set is unchanged, so counting recursively restores the
assertion's original meaning and is layout-agnostic.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 92cf7468-29cb-4aaa-b7f0-962f0c3c55e4
Copilot AI balanced review requested due to automatic review settings September 1, 2026 19:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused change correctly handles both flat and namespace-nested binding layouts.

Pull request overview

Updates the Electron sample test to support namespace-nested generated bindings.

Changes:

  • Counts generated JavaScript files recursively.
  • Documents why recursive enumeration is required.
File summaries
File Description
samples/electron/test.Tests.ps1 Recursively validates generated JS bindings.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Jaylyn-Barbee
Jaylyn Barbee (Jaylyn-Barbee) merged commit bfedc34 into main Sep 1, 2026
31 checks passed
@Jaylyn-Barbee
Jaylyn Barbee (Jaylyn-Barbee) deleted the jay/fix-electron-bindings-recurse branch September 1, 2026 20:03
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.

4 participants