Skip to content

Fix missing [SupportedOSPlatform] on projected members for newer SDK versions#2381

Open
Sergio0694 wants to merge 2 commits intomasterfrom
fix/supported-os-platform-members-master
Open

Fix missing [SupportedOSPlatform] on projected members for newer SDK versions#2381
Sergio0694 wants to merge 2 commits intomasterfrom
fix/supported-os-platform-members-master

Conversation

@Sergio0694
Copy link
Copy Markdown
Member

Summary

Fixes [SupportedOSPlatform]\ not being emitted on projected class members that require a newer OS version than their containing type.

Root Cause

Two issues in \get_contract_platform()\ in \src/cswinrt/helpers.h:

  1. Outdated contract-to-platform mapping table — generated from the 10.0.19041.0 SDK, missing all contract versions introduced in later SDK releases (20348, 22000, 22621, 26100). When a contract version wasn't in the table, the function returned empty and the attribute was silently dropped.

  2. Exact-match requirement for contract versions — the \PreviousPlatforms.xml\ only lists the highest contract version per platform release (e.g., \UniversalApiContract\ v19 for 10.0.26100.0). Intermediate versions like v16/v17/v18 (also introduced in 10.0.26100.0) had no exact table entry, so they also produced no attribute.

Example

\AppExtensionCatalog\ (UAC v3 = 10.0.14393.0) implements \IAppExtensionCatalog2\ (UAC v17), which contains the \FindAll\ method. Before this fix, UAC v17 was not found in the table, so \FindAll\ got no [SupportedOSPlatform]\ attribute despite requiring 10.0.26100.0.

Changes

Commit 1: Update contract-to-platform version mappings

  • Regenerated the \contract_mappings\ table from 10.0.26100.0 \PreviousPlatforms.xml\
  • Added missing versions for \UniversalApiContract\ (v12/14/15/19), \IsolatedWindowsEnvironmentContract, \CloudFilesContract, and others
  • Added 2 new contracts: \ProfileRetailInfoContract, \UIAutomationContract\
  • Updated \PreviousPlatforms.linq\ to reference the 26100 SDK

Commit 2: Fix gap contract version lookup

  • Removed the exact-match requirement from the version lookup in \get_contract_platform()\
  • \lower_bound\ already finds the correct platform for in-between versions (e.g., UAC v17 → 10.0.26100.0 via the v19 entry), since a version not present in a lower platform must have been introduced with the next higher one

Sergio0694 and others added 2 commits April 4, 2026 20:55
The contract_mappings table in get_contract_platform() was generated from
the 10.0.19041.0 SDK and was missing all contract versions introduced in
later SDK releases (20348, 22000, 22621, 26100). When the code generator
could not find a contract version in this table, it silently skipped
emitting [SupportedOSPlatform] for that member, causing projected members
with newer version requirements to be missing the attribute entirely.

Regenerated the table from 10.0.26100.0 PreviousPlatforms.xml. Key
additions include:
- UniversalApiContract versions 12/14/15/19
- IsolatedWindowsEnvironmentContract versions 3/4/5
- CloudFilesContract versions 6/7
- New contracts: ProfileRetailInfoContract, UIAutomationContract
- Several other contracts with new version entries

Also updated the PreviousPlatforms.linq helper script to reference the
10.0.26100.0 SDK.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The PreviousPlatforms.xml only lists the highest contract version per
platform release. When multiple contract versions are introduced in the
same platform (e.g., UniversalApiContract v16-v19 all in 10.0.26100.0),
only the highest (v19) appears in the mapping table. Types annotated
with an intermediate version (e.g., v17) would fail the exact-match
lookup and silently produce no [SupportedOSPlatform] attribute.

Fix by removing the exact-match requirement from get_contract_platform.
The function already uses lower_bound to find the first table entry with
contract_version >= the requested version, which correctly resolves to
the platform that introduced that version. For example, UAC v17 now
resolves to 10.0.26100.0 (via the v19 entry), since 10.0.22621.0 only
has up to v15.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant