Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/agents/e2e-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ You run and manage the dynwinrt end-to-end test suite.

```powershell
# Run all E2E tests
.\tests\e2e_test.ps1 -SkipBuild
.\tests\e2e\e2e_test.ps1 -SkipBuild

# Python only
.\tests\e2e_test.ps1 -SkipBuild -Lang py
.\tests\e2e\e2e_test.ps1 -SkipBuild -Lang py

# Classic COM only (requires Windows.Win32.winmd)
.\tests\e2e_test.ps1 -SkipBuild -Lang com
.\tests\e2e\e2e_test.ps1 -SkipBuild -Lang com

# Full build + test
.\tests\e2e_test.ps1
.\tests\e2e\e2e_test.ps1
```

## Adding test cases

Add entries to `tests/e2e_specs.json`. See `tests/e2e_specs.schema.json` for the field definitions.
Add entries to `tests/e2e/e2e_specs.json`. See `tests/e2e/e2e_specs.schema.json` for the field definitions.

Safe WinRT APIs to test (no extra dependencies):
- `Windows.Foundation`: Uri, PropertyValue, WwwFormUrlDecoder, MemoryBuffer
Expand All @@ -42,6 +42,6 @@ Avoid APIs that need WinAppSDK, network, or user interaction.

## Diagnosing failures

1. Check `tests/e2e_generated/results_py.json` or `results_ts.json` for structured failure details
2. Inspect generated code in `tests/e2e_generated/python_bindings/`, `ts/`, or `com/`
1. Check `tests/e2e/e2e_generated/results_py.json` or `results_ts.json` for structured failure details
2. Inspect generated code in `tests/e2e/e2e_generated/python_bindings/`, `ts/`, or `com/`
3. Common issues: circular imports in codegen, naming mismatch (Python snake_case vs TS camelCase)
10 changes: 5 additions & 5 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cargo run -p dynwinrt-codegen -- generate --namespace Windows.Foundation --class
cargo run -p dynwinrt-codegen -- generate --namespace Windows.Foundation --class-name Uri --lang py --output ./generated

# E2E test (full pipeline: winmd → generate → call real WinRT APIs)
.\tests\e2e_test.ps1 -SkipBuild -Lang py
.\tests\e2e\e2e_test.ps1 -SkipBuild -Lang py
```

## E2E Testing
Expand All @@ -49,15 +49,15 @@ The E2E test framework validates the full pipeline: reading .winmd metadata →

### How it works

1. **Test specs** are defined in `tests/e2e_specs.json` (schema: `tests/e2e_specs.schema.json`) — each entry describes:
1. **Test specs** are defined in `tests/e2e/e2e_specs.json` (schema: `tests/e2e/e2e_specs.schema.json`) — each entry describes:
- `instantiate`: how to create an instance (`activate`, `static_factory`, or `none`)
- `checks`: array of assertions (`property_equals`, `property_exists`, `method_equals`, `method_result_contains`, `static_equals`, `static_not_null`)

2. **Runners** (`tests/runners/py_runner.py`, `tests/runners/ts_runner.ts`, and `tests/runners/com/*.mjs`) execute generated WinRT and Classic COM bindings.
2. **Runners** (`tests/e2e/runners/py_runner.py`, `tests/e2e/runners/ts_runner.ts`, and `tests/e2e/runners/com/*.mjs`) execute generated WinRT and Classic COM bindings.

3. **Orchestrator** (`tests/e2e_test.ps1`) handles build, temporary code generation, and runner invocation. Use `-Lang com` for the Classic COM suite; it requires `DYNWINRT_WIN32_WINMD` or an installed `Microsoft.Windows.SDK.Win32Metadata` package.
3. **Orchestrator** (`tests/e2e/e2e_test.ps1`) handles build, temporary code generation, and runner invocation. Use `-Lang com` for the Classic COM suite; it requires `DYNWINRT_WIN32_WINMD` or an installed `Microsoft.Windows.SDK.Win32Metadata` package.

4. **Adding new test cases**: Add entries to `e2e_specs.json`:
4. **Adding new test cases**: Add entries to `tests/e2e/e2e_specs.json`:
```json
{
"namespace": "Windows.Foundation",
Expand Down
4 changes: 2 additions & 2 deletions .github/skills/classic-com-abi/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Use this skill for changes under:
- `bindings/js/src/com.rs`;
- `tools/dynwinrt-codegen/src/com_metadata.rs`;
- `tools/dynwinrt-codegen/src/codegen/com/`; or
- Classic COM runners in `tests/runners/com/`.
- Classic COM runners in `tests/e2e/runners/com/`.

Read [`docs/classic-com-support.md`](../../../docs/classic-com-support.md)
Read [`docs/architecture/classic-com-support.md`](../../../docs/architecture/classic-com-support.md)
before changing supported types or claiming support for an interface.

## Core principle
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
.\bindings\py\.venv\Scripts\python.exe -m pytest bindings\py\tests -q
.\bindings\py\.venv\Scripts\python.exe -m mypy.stubtest dynwinrt_py --allowlist bindings\py\stubtest_allowlist.txt --ignore-disjoint-bases
- name: Run E2E tests
run: .\tests\e2e_test.ps1 -SkipBuild
run: .\tests\e2e\e2e_test.ps1 -SkipBuild

# dynwinrt-codegen (x64 + arm64)
dynwinrt-codegen:
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:
- '.github/workflows/python-release.yml'
- 'bindings/py/**'
- 'crates/dynwinrt/**'
- 'scripts/test_python_*_wheel.ps1'
- 'scripts/verify_python_release.py'
- 'eng/release/python/test_python_*_wheel.ps1'
- 'eng/release/python/verify_python_release.py'
- 'tools/dynwinrt-codegen/**'
- 'Cargo.lock'
- 'Cargo.toml'
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
$version = [regex]::Match($cargo, '(?m)^version = "([^"]+)"$').Groups[1].Value
if (-not $version) { throw 'Could not read bindings/py Cargo version' }

$arguments = @('scripts\verify_python_release.py', 'source')
$arguments = @('eng\release\python\verify_python_release.py', 'source')
if ($env:RELEASE_VERSION) {
$arguments += @('--release-version', $env:RELEASE_VERSION)
}
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$wheel = @(Get-ChildItem artifacts\runtime\*.whl)
if ($wheel.Count -ne 1) { throw "Expected one runtime wheel, found $($wheel.Count)" }
python scripts\verify_python_release.py wheel `
python eng\release\python\verify_python_release.py wheel `
--wheel $wheel[0].FullName `
--package dynwinrt-py `
--version $env:VERSION `
Expand Down Expand Up @@ -159,7 +159,7 @@ jobs:
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$wheel = @(Get-ChildItem artifacts\runtime\*.whl)
if ($wheel.Count -ne 1) { throw "Expected one runtime wheel, found $($wheel.Count)" }
python scripts\verify_python_release.py wheel `
python eng\release\python\verify_python_release.py wheel `
--wheel $wheel[0].FullName `
--package dynwinrt-py `
--version $env:VERSION `
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$wheel = @(Get-ChildItem artifacts\codegen\*.whl)
if ($wheel.Count -ne 1) { throw "Expected one codegen wheel, found $($wheel.Count)" }
python scripts\verify_python_release.py wheel `
python eng\release\python\verify_python_release.py wheel `
--wheel $wheel[0].FullName `
--package dynwinrt-codegen `
--version $env:VERSION `
Expand Down Expand Up @@ -233,7 +233,7 @@ jobs:
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$wheel = @(Get-ChildItem artifacts\codegen\*.whl)
if ($wheel.Count -ne 1) { throw "Expected one codegen wheel, found $($wheel.Count)" }
python scripts\verify_python_release.py wheel `
python eng\release\python\verify_python_release.py wheel `
--wheel $wheel[0].FullName `
--package dynwinrt-codegen `
--version $env:VERSION `
Expand Down Expand Up @@ -264,10 +264,10 @@ jobs:
run: |
python -m pip install "packaging>=24,<27" --quiet
$wheel = @(Get-ChildItem artifacts\codegen\*.whl)
python scripts\verify_python_release.py wheel --wheel $wheel[0].FullName `
python eng\release\python\verify_python_release.py wheel --wheel $wheel[0].FullName `
--package dynwinrt-codegen --version '${{ needs.validate.outputs.version }}' `
--python-tag py3 --abi-tag none --platform-tag win_amd64
.\scripts\test_python_codegen_wheel.ps1 -Python (Get-Command python).Source `
.\eng\release\python\test_python_codegen_wheel.ps1 -Python (Get-Command python).Source `
-WheelDirectory artifacts\codegen `
-Version '${{ needs.validate.outputs.version }}' -Architecture x64

Expand All @@ -289,7 +289,7 @@ jobs:
shell: pwsh
run: |
python -m pip install "packaging>=24,<27" --quiet
.\scripts\test_python_codegen_wheel.ps1 -Python (Get-Command python).Source `
.\eng\release\python\test_python_codegen_wheel.ps1 -Python (Get-Command python).Source `
-WheelDirectory artifacts\codegen `
-Version '${{ needs.validate.outputs.version }}' -Architecture arm64

Expand Down Expand Up @@ -321,7 +321,7 @@ jobs:
- name: Import wheel and call Windows.Foundation.Uri
shell: pwsh
run: |
.\scripts\test_python_runtime_wheel.ps1 -Python (Get-Command python).Source `
.\eng\release\python\test_python_runtime_wheel.ps1 -Python (Get-Command python).Source `
-RuntimeWheelDirectory artifacts\runtime `
-CodegenWheelDirectory artifacts\codegen `
-Version '${{ needs.validate.outputs.version }}' `
Expand Down Expand Up @@ -356,7 +356,7 @@ jobs:
- name: Import native wheel and call Windows.Foundation.Uri
shell: pwsh
run: |
.\scripts\test_python_runtime_wheel.ps1 -Python (Get-Command python).Source `
.\eng\release\python\test_python_runtime_wheel.ps1 -Python (Get-Command python).Source `
-RuntimeWheelDirectory artifacts\runtime `
-CodegenWheelDirectory artifacts\codegen `
-Version '${{ needs.validate.outputs.version }}' `
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/winui-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
- name: Run live Python WinUI ARM64 E2E
shell: pwsh
run: |
.\tests\python_winui_e2e.ps1 `
.\tests\e2e\python_winui_e2e.ps1 `
-WinuiWinmd $env:WINUI_WINMD `
-RefList $env:WINUI_REFS `
-BootstrapDll $env:WINUI_BOOTSTRAP `
Expand Down
13 changes: 10 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ mono_crash.*
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
!eng/release/
!eng/release/python/
!eng/release/python/**
x64/
x86/
[Ww][Ii][Nn]32/
Expand Down Expand Up @@ -433,11 +436,15 @@ target
**/generated
**/node_modules
tools/dynwinrt-codegen/npm/bin/**/*.exe
bench-electron/out/
!benchmarks/electron/out/
benchmarks/electron/out/*
!benchmarks/electron/out/preload/
benchmarks/electron/out/preload/*
!benchmarks/electron/out/preload/index.js
**/build

# Claude Code local settings
**/settings.local.json
# Generated E2E projections are recreated and removed by tests/e2e_test.ps1.
tests/e2e_generated/
# Generated E2E projections are recreated and removed by tests/e2e/e2e_test.ps1.
tests/e2e/e2e_generated/
.python-release/
2 changes: 1 addition & 1 deletion .pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,4 @@ extends:
cd bindings/py
if (Test-Path .venv) { .venv/Scripts/Activate.ps1 }
cd ../..
.\tests\e2e_test.ps1 -SkipBuild
.\tests\e2e\e2e_test.ps1 -SkipBuild
11 changes: 7 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ dynwinrt/
│ └── py/ # Python bindings (PyO3)
├── tools/
│ └── dynwinrt-codegen/ # Code generator (JS + .d.ts and Python from .winmd)
├── tests/ # Integration tests & sample projects
└── bench-electron/ # Electron benchmark app
├── tests/e2e/ # Cross-language E2E specs, runners, and scripts
├── benchmarks/ # Electron and JS/native benchmarks
├── samples/ # JavaScript and Python samples
├── docs/ # Architecture, benchmark, guide, and status docs
└── eng/release/python/ # Python release verification helpers
```

## Build Commands
Expand Down Expand Up @@ -175,12 +178,12 @@ let result = value.wait()?;
## Known Limitations

- Delegate callbacks support up to 2 ABI parameters (covers ~95% of WinRT delegates)
- No DispatcherQueue / XAML hosting support (data APIs only, no UI framework) — WinUI-style controls need composition/aggregation of runtime classes, which the codegen skips (see composable `.ctor` note in `TODO.md`)
- No DispatcherQueue / XAML hosting support (data APIs only, no UI framework) — WinUI-style controls need composition/aggregation of runtime classes, which the codegen skips (see composable `.ctor` note in `docs/status/TODO.md`)
- Python binding does not yet support async/await integration with `asyncio`

## Environment Setup — updated invariant

`initialize_winappsdk()` currently `.expect(...)`s the `WINAPPSDK_BOOTSTRAP_DLL_PATH` environment variable at `crates/dynwinrt/src/winapp.rs:43`. Auto-detection from `~/.winapp/packages/`, `~/.nuget/packages/microsoft.windowsappsdk.*/`, and Program Files install paths is tracked in `TODO.md` P0.
`initialize_winappsdk()` currently `.expect(...)`s the `WINAPPSDK_BOOTSTRAP_DLL_PATH` environment variable at `crates/dynwinrt/src/winapp.rs:43`. Auto-detection from `~/.winapp/packages/`, `~/.nuget/packages/microsoft.windowsappsdk.*/`, and Program Files install paths is tracked in `docs/status/TODO.md` P0.

## Implementation Notes

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
members = [
"crates/dynwinrt",
"bindings/js",
"bindings/js/static-bench-rust",
"benchmarks/js/static-rust",
"bindings/py",
"tools/dynwinrt-codegen",
]
Expand Down
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ console.log(uri.host); // "example.com"
Classic COM bindings import their runtime API from the separate
`@microsoft/dynwinrt/com` subpath. It is part of the same npm package; the
package root remains the WinRT-only API. See
[Classic COM support](docs/classic-com-support.md) for the supported ABI,
[Classic COM support](docs/architecture/classic-com-support.md) for the supported ABI,
common-interface test matrix, unsupported native types, and ownership rules.

Generated bindings project unambiguous public WinRT activation metadata as JavaScript
Expand Down Expand Up @@ -114,8 +114,16 @@ dynwinrt/
│ └── py/ # Python bindings (PyO3; release workflow ready)
├── tools/
│ └── dynwinrt-codegen/ # @microsoft/dynwinrt-codegen — typed-binding generator
├── tests/ # Integration tests + sample E2E projects
└── bench-electron/ # Electron benchmark app
├── tests/
│ └── e2e/ # Cross-language E2E specs, runners, and scripts
├── benchmarks/
│ ├── electron/ # Electron IPC benchmark app
│ └── js/ # Dynamic and static JS/native benchmarks
├── samples/
│ ├── js/ # JavaScript/TypeScript samples
│ └── python/ # Python samples
├── docs/ # Architecture, benchmark, guide, and status docs
└── eng/release/python/ # Python release verification helpers
```

## Build from source
Expand All @@ -142,7 +150,10 @@ Rust installation at consumption time. Release and trusted-publishing
instructions are in [`bindings/py/README.md`](bindings/py/README.md).

Python runtime, codegen, packaging, and WinUI readiness are tracked in
[`PYTHON_CHECKLIST.md`](PYTHON_CHECKLIST.md).
[`docs/status/PYTHON_CHECKLIST.md`](docs/status/PYTHON_CHECKLIST.md).

For deployment, see
[Package a dynwinrt Node.js application as MSIX](docs/guides/windows/msix-packaging.md).

## Codegen CLI reference

Expand Down
7 changes: 0 additions & 7 deletions bench-electron/out/preload/index.js

This file was deleted.

7 changes: 7 additions & 0 deletions benchmarks/electron/out/preload/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let electron = require("electron");
//#region src/preload/index.ts
electron.contextBridge.exposeInMainWorld("api", {
ipc: (channel) => electron.ipcRenderer.invoke(channel),
logResults: (lines) => electron.ipcRenderer.invoke("log-results", lines)
});
//#endregion

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"preview": "electron-vite preview"
},
"dependencies": {
"@microsoft/dynwinrt": "file:../bindings/js"
"@microsoft/dynwinrt": "file:../../bindings/js"
},
"devDependencies": {
"@electron-toolkit/preload": "^3.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
// Static C++/WinRT benchmark addon
const require = createRequire(import.meta.url)
const CppBench = require(
join(__dirname, '../../../bindings/js/static-bench-cpp/build/Release/static_bench.node')
join(__dirname, '../../../js/static-cpp/build/Release/static_bench.node')
) as {
uriCreate: (url: string) => unknown
uriGetHost: (url: string) => string
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import {
DynWinRtValue, DynWinRtType, DynWinRtMethodSig, DynWinRtStruct,
WinGuid, roInitialize, RustStaticBench,
rawGetString, rawGetI32,
} from '../dist/winrt.js'
} from '../../bindings/js/dist/winrt.js'
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)
const CppBench = require('../static-bench-cpp/build/Release/static_bench.node')
const RustRawBench = require('../static-bench-rust/static_bench_rust.node')
const CppBench = require('./static-cpp/build/Release/static_bench.node')
const RustRawBench = require('./static-rust/static_bench_rust.node')

roInitialize(1)

Expand Down
Loading
Loading