Proposal: Replace enums.json with conditional C++ enum declarations#2247
Merged
Conversation
jonwis
reviewed
Apr 23, 2026
| ```cpp | ||
| #ifdef _WIN32METADATA_ | ||
|
|
||
| enum __attribute__((flag_enum)) SET_THEME_APP_PROPERTIES_FLAGS : unsigned int { |
Member
There was a problem hiding this comment.
Should this just say DWORD for the type?
| } DISPLAY_DEVICE; | ||
|
|
||
| // Return value | ||
| _Enum_return_(SET_THEME_APP_PROPERTIES_FLAGS) |
Member
There was a problem hiding this comment.
Do we need these macros, since the symbol is already a DWORD for non-metadata runs, and a ProperTypeWithMembers otherwise?
Member
Author
There was a problem hiding this comment.
This was an alternate option in the proposal. The winning proposal doesn't need it. I'll make sure it's clearer.
Add enum remapping proposal and metadata derivation spec: - docs/copilot/plans/enum-remapping-proposal.md: Proposal for replacing enums.json with conditional C++ enum declarations in headers using [[clang::flag_enum]], DEFINE_ENUM_FLAG_OPERATORS, and the #else #define NAME DWORD pattern. Validated end-to-end. - docs/spec.md: High-level spec of how win32metadata derives each construct from SDK headers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
e7a306b to
933d34c
Compare
Per jonwis feedback: unscoped enum leaks member names into the enclosing namespace. Use enum class (scoped enum) throughout to keep member names scoped to the enum type. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jonwis
approved these changes
Apr 28, 2026
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.
Proposal for review
This PR adds documentation proposing how to replace
enums.json(~37K lines, ~1,072 enum definitions) with conditional C++ enum declarations in SDK headers.No code changes — this PR contains only
.mdfiles for review and discussion.Documents
docs/copilot/plans/enum-remapping-proposal.md— The full proposal, including:#ifdef _WIN32METADATA_/#else #define NAME DWORD)[[clang::flag_enum]]+DEFINE_ENUM_FLAG_OPERATORSdocs/spec.md— High-level spec of how win32metadata derives each metadata construct from SDK headers (types, functions, constants, enums, COM interfaces, annotations)Validated
The proposed approach was validated end-to-end (in a separate local branch):
SET_THEME_APP_PROPERTIES_FLAGSin enums.json with a conditional enum inUxtheme.h[Flags], and typed function signaturesWindows.Win32.Testspassed