dart-windows / win32

Build Win32 apps with Dart!
https://win32.pub
BSD 3-Clause "New" or "Revised" License
735 stars 118 forks source link

Deprecate constants for the Win32 enumerations #832

Closed halildurmus closed 3 months ago

halildurmus commented 3 months ago

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:

Screenshot 2024-03-21 160312

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.