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
28 changes: 14 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
if ($result.eligible_interfaces -ne 7929) {
throw "Classic COM census denominator changed: $($result.eligible_interfaces)"
}
if ($result.complete_interfaces -lt 5697) {
if ($result.complete_interfaces -lt 5721) {
throw "Classic COM complete coverage regressed: $($result.complete_interfaces)"
}
if ($result.coverage_percent -lt 70.0) {
Expand All @@ -111,14 +111,14 @@ jobs:
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$result = Get-Content (Join-Path $output 'classic-com-capability-summary.json') -Raw |
ConvertFrom-Json
if ($result.eligible_interfaces -ne 7929 -or $result.safe_complete -ne 5697) {
if ($result.eligible_interfaces -ne 7929 -or $result.safe_complete -ne 5721) {
throw "Classic COM safe totals changed in capability census"
}
$support = Import-Csv (Join-Path $output 'classic-com-interface-support.csv')
if (
@($support).Count -ne 7929 -or
@($support | Where-Object { $_.safe_complete -eq 'true' }).Count -ne 5697 -or
@($support | Where-Object { $_.safe_complete -eq 'false' }).Count -ne 2232
@($support | Where-Object { $_.safe_complete -eq 'true' }).Count -ne 5721 -or
@($support | Where-Object { $_.safe_complete -eq 'false' }).Count -ne 2208
) {
throw "Classic COM compact interface support index changed"
}
Expand All @@ -129,9 +129,9 @@ jobs:
}
}
$expected = @{
x64 = @(412, 1431, 389)
i686 = @(411, 1408, 413)
arm64 = @(412, 1431, 389)
x64 = @(388, 1431, 389)
i686 = @(387, 1408, 413)
arm64 = @(388, 1431, 389)
}
foreach ($target in @('x64', 'i686', 'arm64')) {
$counts = $result.targets.$target
Expand All @@ -144,16 +144,16 @@ jobs:
}
}
if (
$result.safeEvidence.safeComplete -ne 5697 -or
$result.safeEvidence.standardDerived -ne 5332 -or
$result.safeEvidence.exactRegistryDependent -ne 365 -or
$result.safeEvidence.metadataFactOccurrences -ne 5983 -or
$result.safeEvidence.comStandardFactOccurrences -ne 26134 -or
$result.safeEvidence.safeComplete -ne 5721 -or
$result.safeEvidence.standardDerived -ne 5355 -or
$result.safeEvidence.exactRegistryDependent -ne 366 -or
$result.safeEvidence.metadataFactOccurrences -ne 6012 -or
$result.safeEvidence.comStandardFactOccurrences -ne 26247 -or
$result.safeEvidence.registeredExactEntries -ne 532 -or
$result.safeEvidence.metadataMatchedExactEntries -ne 532 -or
$result.safeEvidence.safeConsumedExactEntries -ne 431 -or
$result.safeEvidence.exactEntryInterfaceDependencies -ne 693 -or
$result.safeEvidence.exactFamilyInterfaceDependencies -ne 424
$result.safeEvidence.exactEntryInterfaceDependencies -ne 694 -or
$result.safeEvidence.exactFamilyInterfaceDependencies -ne 425
) {
throw "Classic COM safe evidence dependency census changed"
}
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,20 @@ can omit the bootstrap call.
Classic COM support is functional and tested, but remains a **preview under
active development**. It targets a conservatively validated subset of
`IUnknown`- and `IInspectable`-rooted interfaces from `Windows.Win32.winmd`; it
is not a general Automation or native Win32 projection, and it does not project
flat DLL exports.
is not a general Automation or native Win32 projection, and it does not provide
general flat DLL export projection.

The current CI baseline against
`Microsoft.Windows.SDK.Win32Metadata` 71.0.14-preview is **5,697 of 7,929
eligible interfaces (71.85%)** with complete safe code generation. Supported
`Microsoft.Windows.SDK.Win32Metadata` 71.0.14-preview is **5,721 of 7,929
eligible interfaces (72.15%)** with complete safe code generation. Supported
contracts include generated coclass activation and QueryInterface views,
managed interface ownership, native POD layouts, typed counted buffers,
BSTR/HSTRING, validated VARIANT, SAFEARRAY and PROPVARIANT subsets, the
target-device-independent `TYMED_HGLOBAL` FORMATETC/STGMEDIUM subset,
variable-length WAVEFORMATEX audio formats with exact CoTaskMem outputs, and
synchronous JavaScript implementations of fully supported callback interfaces.
Separate bounded one-shot audio activation and owned-copy transactions are
also available; copy-only facades are not counted as complete interfaces.
Seventeen stock-Windows Node E2E runners exercise representative Shell,
Automation, stream, callback, HWND, and WinRT interop scenarios.

Expand Down Expand Up @@ -178,6 +180,14 @@ the documented in-process, null-parameter audio endpoint subset and
`activate(IAudioClient)` and `DynComAudioFormat.pcm()` format negotiation,
without a per-interface native adapter.

Existing distinguishable overloads keep their APIs unchanged. Otherwise fully
validated normal COM overload groups with colliding JavaScript signatures or
projected buffers now expose every member as
`<camelName>AtSlot<absoluteVtableSlot>`, with no ambiguous unsuffixed method.
This naming-only projection promotes 24 interfaces; it does not guess ABI
contracts or provide a universal overload parser. See the
[overload usage and limits](docs/guides/windows/classic-com-usage.md#58-explicit-overload-names).

- [Classic COM JavaScript usage guide](docs/guides/windows/classic-com-usage.md)
- [Supported ABI, coverage, limitations, and ownership model](docs/architecture/classic-com-support.md)

Expand Down
42 changes: 27 additions & 15 deletions docs/architecture/classic-com-contract-evidence-registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ Current code registries are migrated without changing behavior:
- exact fail-closed hazards such as `GetPrivateData`.

Migration or promotion is complete only when generated safe snapshots, the
5,697/7,929 safe census, generated unsafe manifests, and all live tests agree
5,721/7,929 safe census, generated unsafe manifests, and all live tests agree
with the exact evidence dependencies.

## User contracts
Expand Down Expand Up @@ -448,19 +448,27 @@ The safe-complete evidence census is:

| Evidence class | Safe interfaces |
| --- | ---: |
| `standard_derived` | 5,332 |
| `exact_registry_dependent` | 365 |
| **Total** | **5,697** |
| `standard_derived` | 5,355 |
| `exact_registry_dependent` | 366 |
| **Total** | **5,721** |

The registry contains **532 declared entries**, all 532 match the pinned
metadata, and 431 distinct entries are consumed by complete safe plans. These plans have
693 entry/interface dependencies and 424 family/interface dependencies.
Per-interface dependency-set totals also include 5,983 metadata-attribute
dependencies and 26,134 COM-standard-rule dependencies.
694 entry/interface dependencies and 425 family/interface dependencies.
Per-interface dependency-set totals also include 6,012 metadata-attribute
dependencies and 26,247 COM-standard-rule dependencies.

PR4's explicit overload names promote 24 previously raw-metadata-complete
interfaces: 23 standard-derived and one exact-registry-dependent.
`IGenericDescriptor2` now consumes the existing `IGenericDescriptor::GetBody`
slot-6 ownership entry, bringing that entry's interface dependencies from one
to two. No entries are added: registered/matched and distinct safe-consumed
entry counts remain 532 and 431. The new names select already validated
normal methods; they do not supply missing ABI, ownership, or lifetime facts.

| Exact contract kind | Safe-interface dependencies |
| --- | ---: |
| `ownership` | 182 |
| `ownership` | 183 |
| `parameter-direction` | 45 |
| `bounded-two-call` | 16 |
| `conditional-output` | 10 |
Expand All @@ -485,7 +493,7 @@ Family rollups deliberately count each interface once per family:
| `com.sequential-stream-buffer.v1` | 2 | 2 | 7 |
| `buffers.counted-buffer.v1` | 3 | 2 | 2 |
| `buffers.bounded-two-call.v1` | 2 | 2 | 16 |
| `com.ownership.v1` | 169 | 118 | 123 |
| `com.ownership.v1` | 169 | 118 | 124 |
| `com.parameter-direction.v1` | 3 | 3 | 15 |
| `com.reserved-null-input.v1` | 2 | 2 | 1 |
| `com.nullable-input.v1` | 2 | 2 | 2 |
Expand Down Expand Up @@ -518,12 +526,12 @@ Universal rule dependencies are:
| `com.automation.bstr-replacement.v1` | 99 |
| `com.enumerator-next.generic.v1` | 25 |
| `com.handle.borrowed-no-cleanup.v1` | 45 |
| `com.hresult.failure.v1` | 5,579 |
| `com.interface.input-borrow.v1` | 1,890 |
| `com.interface.typed-output-plus-one.v1` | 3,458 |
| `com.iunknown.identity-refcount.v1` | 5,697 |
| `com.query-interface.output-plus-one.v1` | 5,697 |
| `com.standard-cleanup.matching-allocator.v1` | 1,437 |
| `com.hresult.failure.v1` | 5,603 |
| `com.interface.input-borrow.v1` | 1,908 |
| `com.interface.typed-output-plus-one.v1` | 3,480 |
| `com.iunknown.identity-refcount.v1` | 5,721 |
| `com.query-interface.output-plus-one.v1` | 5,721 |
| `com.standard-cleanup.matching-allocator.v1` | 1,438 |

These are dependency counts: an inherited contract can be consumed by several
interfaces, and one interface can consume several IDs or kinds. They are not
Expand Down Expand Up @@ -575,3 +583,7 @@ helpers. Delete existing generated bindings and completely regenerate every
selected root with matching updated runtime/codegen versions; there is no
in-place migration or support for mixed old/new generated classes. The
contract-data schema is unaffected, as are other generated `.as(...)` paths.

PR4 requires no further manifest change. Already-supported safe output,
including distinguishable overload dispatch, remains byte-identical;
previously rejected overload groups had no valid safe surface to migrate.
31 changes: 25 additions & 6 deletions docs/architecture/classic-com-generated-unsafe.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,23 @@ Codegen uses the same capability classifier as `com-capability-census`.
The complete inherited interface passes the existing safe semantic projection.
Generate the existing safe class and no unsafe replacement.

PR4 resolves previously rejected overload groups only after every member has a
fully validated normal COM call plan. Colliding JavaScript arity/shapes or
projected buffers receive explicit
`<camelName>AtSlot<absoluteVtableSlot>` names for every member, with no
ambiguous unsuffixed method. Existing distinguishable dispatch stays
unchanged; collisions with projected members and synthesized/dynamic-IID/
non-normal groups still fail closed. Renderers consume the selected IR names
without guessing runtime types or native semantics.

This promotes 24 raw-metadata-complete interfaces, bringing complete safe
coverage to **5,721 / 7,929** and leaving **2,208** incomplete interfaces.
Promoted interfaces receive no duplicate unsafe companion. Native ABI,
conversion, lifetime, and raw-runtime capabilities remain unchanged, and
PR3's copy-only facades remain excluded from complete safe coverage.
Already-supported safe output remains byte-identical, so PR4 needs no
additional manifest version.

### Raw metadata complete

Metadata contains every fact needed to express the outbound ABI through Phase 1
Expand Down Expand Up @@ -598,7 +615,7 @@ trailing dots/spaces, and Windows device names (`CON`, `PRN`, `AUX`, `NUL`,
`CLOCK$`, `CONIN$`, `CONOUT$`, `COM1`-`COM9`, and `LPT1`-`LPT9`), including
device names with extensions.

Retained schema-11 `modulePath` is never trusted. Codegen rederives it from the
Retained schema-12 `modulePath` is never trusted. Codegen rederives it from the
validated qualified interface identity and exact `<Interface>Unsafe` class
name, requires an exact match, and then checks the case-insensitive path key.
Case-only namespaces or type names therefore fail instead of aliasing on
Expand Down Expand Up @@ -707,17 +724,19 @@ Stage 2 is implemented:
arguments;
- parameter requirements come from the same per-target classifier analysis;
- runtime-blocked methods remain omitted;
- support schema 11 records every parameter index/name, strategy type, exact
- support schema 12 records every parameter index/name, strategy type, exact
reason, native direction/nullability, and known target pointee layouts; and
- a raw pointer is never substituted for missing ownership.

For official 71.0.14 metadata, **1,442 of 1,446** x64 manual-contract interfaces
have at least one portable executable generated high-level method. **1,441**
For official 71.0.14-preview metadata, **1,427 of 1,431** x64 manual-contract interfaces
have at least one portable executable generated high-level method. **1,426**
have an executable manual method, one retains only metadata-complete methods,
and four have no portable executable method because every candidate is blocked
on another generated target. There are **6,083** portable executable manual
on another generated target. There are **6,046** portable executable manual
methods, **0** remaining portable manual-classified methods omitted, and
**1,163** cross-target runtime-blocked methods still omitted.
**1,161** cross-target runtime-blocked methods still omitted. The existing
`official_stage2_coverage_is_exact` test confirms these measurements are
unchanged by PR4; its promotions come from the raw-metadata-complete bucket.

### Stage 3

Expand Down
43 changes: 35 additions & 8 deletions docs/architecture/classic-com-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
general Automation or native Win32 projection.

> **Status: preview, under active development.** The current CI baseline against
> `Microsoft.Windows.SDK.Win32Metadata` 71.0.14-preview is 5,697 complete safe
> interface projections out of 7,929 eligible interfaces (71.85%). Earlier
> `Microsoft.Windows.SDK.Win32Metadata` 71.0.14-preview is 5,721 complete safe
> interface projections out of 7,929 eligible interfaces (72.15%). Earlier
> inventory and demand-snapshot sections retain the metadata versions and dates
> stated in those sections.

Expand Down Expand Up @@ -154,6 +154,31 @@ renderer cannot see `TypeMeta` or metadata attributes and has no default
pointer/Buffer fallback; it only serializes the validated projected IR with
exhaustive type matches.

## Explicit COM overload names

Existing overload groups with distinguishable JavaScript arity/shape retain
their exact dispatch and generated API. PR4 handles previously rejected
groups only when every member is an otherwise fully validated **normal COM
method**. Groups with colliding JavaScript signatures or projected buffers
receive deterministic public names
`<camelName>AtSlot<absoluteVtableSlot>` for **every** member; the ambiguous
unsuffixed method is absent.

The slot is the absolute inherited vtable slot, not an overload ordinal.
For example, `ID2D1Device1::CreateDeviceContext` produces two explicit
`createDeviceContextAtSlot...` members; the generated declarations give their
exact names and return types. Native method names, slots, ABI signatures,
conversions, and lifetime plans are unchanged. Projection selects the names in
IR; the renderer only serializes them and adds no runtime type or ABI guesses.

Alias collisions with actual projected members fail closed. Synthesized,
dynamic-IID, and other non-normal method groups still reject; this is not a
universal overloaded-method parser or a way around incomplete native
contracts. See the [usage guide](../guides/windows/classic-com-usage.md#58-explicit-overload-names).
PR4 does not change COM manifest version 4 or unsafe support schema 12:
already-supported safe output remains byte-identical, and the newly admitted
groups previously had no valid safe surface.

## Bounded native one-shot completion

The first supported flat export is the exact
Expand Down Expand Up @@ -262,8 +287,8 @@ interface projections. They do not expose `GetBuffer`, `ReleaseBuffer`, `Lock`,
or `Unlock` independently. WIC retains its previously complete native interface
surface (including acquisition of an opaque owned lock) and adds the copy
operation. An external lock never gains byte access or writable rights from
this operation. The complete safe census remains **5,697 / 7,929**; it does not
count the three copy-only facades as newly complete interfaces.
this operation. The three copy-only facades remain excluded from the current
**5,721 / 7,929** complete safe census.

### Private context and lifecycle

Expand Down Expand Up @@ -793,7 +818,7 @@ not be described as solving every problem in the map above.
| Fail-closed generation | Unknown/unsafe layouts, untagged/by-value/output unions, bitfields, flexible arrays, nested owned fields, unsupported VARTYPE/BYREF/SAFEARRAY/PROPVARIANT combinations, unsupported arrays, pointer outputs, ownership, and in/out shapes stop generation with a targeted error. |
| Consumable output | Classic COM files live under `com/`, with `./com` and `./com/*` package exports. The generated package root is always WinRT-only; COM-only output deliberately has no root entrypoint. |
| Explicit vtable registration | Every generated method is registered with `.addMethodAt(vtableIndex, name, signature)`, keyed by its actual metadata-derived vtable slot. Methods are never deduplicated by name, so same-name overloads at different slots both register correctly. |
| Same-name overload projection | Overloads (e.g. `IDCompositionEffectGroup::SetOpacity`) are grouped once during projection (not by renderer heuristics). A single public JS method dispatches to a private per-slot implementation using only a validated, mutually-distinguishable arity/shape key (`typeof`-based: boolean/number/bigint/string/object); ambiguous groups fail generation closed with a diagnostic naming the interface, method, and reason. The `.d.ts` emits one TypeScript overload signature per branch, contiguously. |
| Same-name overload projection | Existing distinguishable overloads (e.g. `IDCompositionEffectGroup::SetOpacity`) retain their single public dispatcher, validated arity/shape keys, and contiguous TypeScript overload signatures. Previously rejected groups of fully validated normal methods use explicit `<camelName>AtSlot<absoluteVtableSlot>` names for every member and omit the ambiguous unsuffixed name. Projection selects these names; the renderer does not infer ABI semantics. Collisions and non-normal groups fail closed. |
| Lifecycle ergonomics | Generated interface wrappers declare a protected constructor (`protected constructor(obj: unknown);`) so only generated coclasses can subclass them. Coclasses expose a public zero-argument constructor, and every wrapper provides an idempotent `release()` that delegates to the managed native value. Factory-activated interop wrappers retain `static create()` with JSDoc reminding callers to initialize COM first. |
| Doc-link rendering | When win32metadata attaches a `DocumentationAttribute` (a `learn.microsoft.com` URL) to a method, the generator renders it as an `@see {@link ...}` comment in both `.js` and `.d.ts`. No raw metadata is imported into the renderer — the URL is threaded through `ProjectedComMethod.doc`, populated once during projection. |
| Acronym-aware parameter casing | Parameter names are lowered using the same acronym-run-aware rule as method names, so a Hungarian-prefixed trailing acronym like `hwndMDI` projects as `mdi` (not the previous naive `mDI`). |
Expand Down Expand Up @@ -1609,13 +1634,15 @@ restricting InOut to proven caller-allocation-preserving contracts, bringing
that census to 5,691. The variable-length WAVEFORMATEX model and three pinned
audio method contracts promote five more interfaces, bringing that census to
5,696. The exact `IMMDevice::Activate` and `GetId` contracts promote one more
complete interface, bringing the current literal census to
**5,697 / 7,929 = 71.850170%**. The result remains above the
complete interface, bringing that census to 5,697, unchanged by PR2 completion
and PR3 copy-only facades. PR4's explicit overload names move 24 previously
raw-metadata-complete interfaces into the safe set, bringing the current
literal census to **5,721 / 7,929 = 72.152857%**. The result remains above the
70% target without admitting any unmodeled target-device, storage-medium,
audio-output ownership, ownership-transfer, or callback shape.

CI reproduces this number with `dynwinrt-codegen com-census --json` and fails
if the denominator changes, complete generation drops below 5,697, or coverage
if the denominator changes, complete generation drops below 5,721, or coverage
falls below 70%.

## Public-code frequency snapshot
Expand Down
Loading