Deprecate constants for the Win32 enumerations #832
Merged
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.
Part of #819
Previously, these constants were manually added as top-level constants. However, with #819, it's no longer feasible to expose all Win32 enumerations this way due to name conflicts. Therefore, to solve this problem, all Win32 enumerations need to be placed under a namespace. Win32 enumerations are also defined this way in the metadata.
For example:
I think extension types are a great choice for organizing the enumerations. They act as a namespace and incur zero-cost. I also have plans to update the parameter types of Win32 functions that accept enumerations to use the corresponding extension type. This adjustment will give users clarity on the acceptable values they can pass, as opposed to the current generic
int
representation.To facilitate this transition, this PR introduces Win32 enums as extension types based on
int
while also deprecating top-level constants. Additionally, this PR includes data-driven fixes to automate the migration process. Tests for deprecated constants have also been added to ensure their values are the same as newly added constants. Thanks to these tests, I also fixed some constants that had incorrect values.