Skip to content

☂️ Move to on-demand Windows API projection #819

@halildurmus

Description

@halildurmus

Background

package:win32 currently ships a pre-generated subset of the Windows API, which covers many common use cases. However, this approach doesn't scale well — the Win32 API surface is enormous, and broadening coverage means unconditionally loading far more Dart code than most users will ever need, placing unnecessary strain on the Dart analyzer.

Proposed Direction

Move to an on-demand projection model, similar to how ffigen works:

  • package:win32 is slimmed down to expose only a small core of helpers and runtime pieces.
  • A new generator package (e.g., package:win32gen) accepts user input declaring which Win32 APIs they need, then emits only the corresponding Dart bindings into their project.
  • The generator could also support customization around naming conventions, projection rules, and filtering.

Benefits

  • Faster analyzer performance — only the APIs a project actually uses are materialized as Dart code.
  • Smaller dependency footprint — users aren't paying the cost for APIs they'll never call.
  • Improved discoverability — generating bindings on demand makes the API selection explicit and documented in the project's config, making it clear to contributors which Win32 APIs a project depends on.
  • More flexibility — projection rules and naming can be customized per-project.

Original issue description

Currently, the JSON files define which APIs are projected by the generator.

In a future major release (not in v6, likely v7), I plan to expand the generator to project nearly the entire Win32 API, excluding a few outdated APIs. This will be made possible by leveraging Microsoft’s metadata, eliminating the need for the manual effort currently required to add new APIs -- a process that is both time-consuming and tedious.

The expanded scope will include:
- Win32 callbacks
- Win32 constants
- Win32 enumerations
- Win32 functions
- Win32 structures
- COM interfaces

Metadata

Metadata

Assignees

Labels

P3Low-priority issueautomationReplace handcrafted code that doesn't scaleepicA theme of work that contain sub-tasksfeatureA new feature or requestpackage: generatorIssue with package:generatorpackage: win32Issue with package:win32

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions