Skip to content

Add SDK header patch system for shift-left metadata annotations#2248

Open
jevansaks wants to merge 3 commits intomainfrom
user/jevansa/sdk-header-patches
Open

Add SDK header patch system for shift-left metadata annotations#2248
jevansaks wants to merge 3 commits intomainfrom
user/jevansa/sdk-header-patches

Conversation

@jevansaks
Copy link
Copy Markdown
Member

SDK Header Patch System

Adds a mechanism to patch SDK headers during ingestion (UpdateSDK.ps1) so we can add metadata annotations (conditional enums, SAL attributes, etc.) while waiting for the official SDK to ship these changes.

How it works

Patches are unified diffs in generation/WinSDK/patches/, organized by phase:

  • pre-midl/ — Applied after SDK copy, before MIDL recompilation. IDL changes flow through MIDL into generated .h files.
  • post-midl/ — Applied after MIDL and header restores. For direct .h patches.

If a patch fails to apply during SDK update, the script errors out — signaling the SDK changed and the patch needs regeneration.

Proof-of-concept patches

  1. Uxtheme.h (post-midl): Adds conditional SET_THEME_APP_PROPERTIES_FLAGS enum under #ifdef _WIN32METADATA_ with typed function signatures. Complements Proposal: Replace enums.json with conditional C++ enum declarations #2247.
  2. amstream.idl (pre-midl): Adds cpp_quote metadata marker that flows through MIDL compilation into the generated amstream.h.

Both validated via full SDK update with version 10.0.26100.7705.

Files changed

File Purpose
scripts/ApplySDKPatches.ps1 Patch application script (phase-based)
scripts/RecompileIdlFilesForScraping.ps1 Hook points for pre-midl and post-midl phases
generation/WinSDK/patches/post-midl/Uxtheme.h.patch Header patch POC
generation/WinSDK/patches/pre-midl/amstream.idl.patch IDL patch POC
docs/sdk_patches.md Documentation

See docs/sdk_patches.md for patch authoring workflow.

Introduces a patch system that modifies SDK headers during ingestion
(UpdateSDK.ps1 / RecompileIdlFilesForScraping.ps1) to add metadata
annotations until the official SDK ships these changes.

Patches are unified diffs in generation/WinSDK/patches/, organized by
phase:
- pre-midl/  : Applied before MIDL recompilation (IDL files, etc.)
- post-midl/ : Applied after MIDL and header restores (.h files)

Includes two proof-of-concept patches:
- Uxtheme.h (post-midl): Adds conditional SET_THEME_APP_PROPERTIES_FLAGS
  enum under #ifdef _WIN32METADATA_ with typed function signatures
- amstream.idl (pre-midl): Adds cpp_quote metadata marker that flows
  through MIDL into the generated amstream.h

Both patches validated via full SDK update (10.0.26100.7705).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jevansaks jevansaks force-pushed the user/jevansa/sdk-header-patches branch from f0d152f to a942a45 Compare April 23, 2026 21:10
jevansaks and others added 2 commits April 28, 2026 10:21
Supports multiple independent patches per header file, each for a
single logical change. Patches are applied in sorted filename order.

Example: Uxtheme.h.set-theme-app-properties-enum.patch

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The patch system (ApplySDKPatches.ps1, hooks in RecompileIdlFilesForScraping.ps1,
docs/sdk_patches.md) is ready for use. POC patches removed to avoid winmd
baseline changes — real patches will be added as shift-left work proceeds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jevansaks jevansaks marked this pull request as ready for review April 28, 2026 22:17
@jevansaks jevansaks requested review from a team and vineeththomasalex as code owners April 28, 2026 22:17
@jevansaks jevansaks requested a review from jonwis April 28, 2026 22:21
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