Skip to content

Fix JavaScript collection input and output contracts - #180

Merged
leileizhang (lei9444) merged 2 commits into
mainfrom
lei9444-fix-js-collection-contracts
Sep 22, 2026
Merged

leileizhang (lei9444) merged 2 commits into
mainfrom
lei9444-fix-js-collection-contracts

Conversation

@lei9444

Copy link
Copy Markdown
Contributor

Changes

  • Reuse metadata-directed IReference<T> boxing for automatic JavaScript array and Map inputs, including native array parameters. Preserve native and managed nulls and existing reference wrappers.
  • Convert JavaScript Map inputs to independently owned IMapView<K,V> snapshots through the generated IMap.getView() operation, releasing the temporary map without changing native QueryInterface behavior.
  • Align collection output declarations with their runtime values across methods, getters, async results, arrays, and collection read helpers. Keep input wrapper types separate from native-value outputs.

Compatibility

Strict TypeScript consumers must guard nullable collection outputs before dereferencing them. A present null remains distinct from the undefined returned by get() for a missing key or at() for an out-of-range index. Array containers, scalar/struct values, and non-null collection factory results are not made nullable.

Map get() propagates conversion and native errors instead of treating them as missing entries. Its HasKey and Lookup calls are separate native operations, not atomic against concurrent native mutation.

Reuse IReference boxing for automatic collection inputs, obtain owned map views through generated GetView, and distinguish nullable output types from input representations. Keep missing map entries distinct from conversion errors and cover strict consumers plus production native roundtrips.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bdea384f-3022-47e8-8c74-11fd768c2105
Record the paired IMap projection without revisiting the same argument subtree. Add a small nested dependency control and clarify that map get uses non-atomic native operations.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bdea384f-3022-47e8-8c74-11fd768c2105
@github-actions

Copy link
Copy Markdown

Mixed-language test coverage

Workflow status: ✅ Passed

Layer Lines Functions Branches/regions
Rust, including native .pyd/.node 86.38% 81.5% 86.02% 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.3% n/a 47.04% branches
JavaScript aggregate 21.93% 25.24% 57.77% branches
JavaScript runtime 44.27% 45.76% 78.99% branches
Generated WinRT projections 22.81% 18.76% 54.84% branches
Generated WinRT implementations 46.01% 59.42% 60.97% 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 5ddd0ee into main Sep 22, 2026
33 checks passed
@lei9444
leileizhang (lei9444) deleted the lei9444-fix-js-collection-contracts branch September 22, 2026 03:58
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