Fix missing [SupportedOSPlatform] on projected members for newer SDK versions#2381
Open
Sergio0694 wants to merge 2 commits intomasterfrom
Open
Fix missing [SupportedOSPlatform] on projected members for newer SDK versions#2381Sergio0694 wants to merge 2 commits intomasterfrom
Sergio0694 wants to merge 2 commits intomasterfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.
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
Commit 2: Fix gap contract version lookup