Skip to main content

Contributing

Thank you for your interest in contributing to package:win32!

This guide provides everything you need to get started and make your contributions effective and rewarding.

We strive to maintain a welcoming and inclusive community, so please read our Code of Conduct before contributing.

๐Ÿ“ Good to Knowโ€‹

  • Working on Issues: If you'd like to work on an existing issue, please comment on the issue page to let others know before you begin.
  • Proposing New Features: Have an idea for a new feature? Create an issue to discuss it with the community and maintainers before diving in.

๐Ÿ™Œ How You Can Contributeโ€‹

  • ๐ŸŒŸ Star Us on GitHub: If you enjoy using this package, a star on GitHub helps support our work.
  • ๐Ÿ› Report Bugs: Found a bug? Let us know on our GitHub Issues page.
  • ๐Ÿ“ Improve Documentation: High-quality documentation is crucial. Help us improve it by refining the existing docs or adding new content.
  • ๐Ÿ’ฌ Give Feedback: Share your experience using package:win32, what features you'd like, and what works well on GitHub Discussions.
  • ๐Ÿ“ข Share package:win32: Spread the word about this project to reach more users.
  • ๐Ÿ’ป Contribute to the Codebase: Work on new features or tackle open issues โ€” all contributions are highly appreciated!
  • ๐Ÿ“ฆ Share Your Own Packages: If you've created a package that builds on top of package:win32 and provides a more Dart-friendly API for a specific Windows API, please share it with us! Our community is growing rapidly, and your package could be useful for many people. We'll be happy to add your package to our packages page and share it with our community.

๐Ÿ› ๏ธ Setting Up the Environmentโ€‹

โš™๏ธ Requirementsโ€‹

If you're planning to contribute to the documentation, you'll also need:

  • Node.js version 20 or higher
  • npm version 10 or higher

Once your environment is ready, fork the repository, clone it locally, and set up the project.

๐Ÿ“ฅ Cloning the Repositoryโ€‹

Clone your fork of package:win32 to your local machine:

Terminal
git clone https://github.com/<your-username>/win32.git

๐Ÿ“ฆ Installing Dependenciesโ€‹

Navigate to the project directory and first activate package:melos globally, then install the dependencies:

Terminal
dart pub global activate melos
dart pub get

๐Ÿงฉ Setting Up Git Hooksโ€‹

This project uses Lefthook to manage Git hooks. Install the hooks by running the following in the project root:

Terminal
lefthook install

This will set up checks that automatically ensure code quality and consistency before commits.

๐Ÿงช Running Testsโ€‹

To run tests for the package:win32, run the following command:

Terminal
melos run test:win32

We require tests for each feature or bug fix. If you're unsure how to write tests for your changes, feel free to ask on the relevant GitHub issue page.

๐Ÿ“ Contributing to the Documentationโ€‹

Our documentation is built with Docusaurus. To contribute to the documentation, you need to install the dependencies and start the development server:

Terminal
> cd website
> npm install
> npm start

Now, head over localhost:3000 to see the documentation.

Development Tip:

To create a production build of the documentation, you can use the npm run build command. Then, you can use the npm run serve command to serve the production build on your local machine.

๐Ÿ’ป Contributing to the package:win32 Itselfโ€‹

If you want to contribute to the package:win32 itself, follow the steps below:

Classic Win32 APIsโ€‹

  • When wrapping a Win32 API, use the Unicode ('W') wide variants of these APIs, rather than the ANSI ('A') variants. For example: CredWriteW, rather than CredWriteA.

  • To create a new API, don't edit the main library files themselves; these get overwritten. Instead, edit the win32_functions.json file and run the melos run generate command to generate the library files:

    Terminal
    melos run generate
  • Constants can be auto-generated by including them in the win32_constants.json file and running the melos run generate command, which will generate the corresponding Dart files.

  • Structs can be auto-generated by including them in the win32_structs.json file and running the melos run generate command, which will generate the corresponding Dart files.

  • There are plenty of good existing patterns to build off in these locations; try to mirror an existing function if you can for consistency!

  • Ideally pull requests for new API submissions include a sample (examples\ directory) and some tests (packages\win32\test\ directory).

COM APIsโ€‹

Begin by editing the com_types.json file, specifying the desired COM interface, and then run the melos run generate command to generate the relevant classes in the packages\win32\lib\src\com directory.

๐Ÿš€ Committing Your Work and Preparing a Pull Requestโ€‹

To maintain a consistent and clean codebase, we enforce coding standards and use tools to ensure high-quality contributions.

๐ŸŽจ Coding Styleโ€‹

Please follow the Dart style guide to keep the codebase clean and consistent.

๐Ÿ“œ Commit Conventionโ€‹

We use Conventional Commits to structure our commit messages for clarity and uniformity.

Please use the following format for commit messages:

<type>(optional scope): <description>

Examples:

  • feat: add DragQueryFile API
  • fix: resolve an issue with the PROPVARIANT struct

Commit messages are validated with a GitHub action, so be sure to use the correct format when making a pull request.

๐Ÿงฉ Git Hooksโ€‹

The following hooks run automatically with Lefthook:

  • Pre-Commit Hooks:

    • analyze: Checks code for style issues.
    • format: Formats code according to Dart guidelines.
    • test_ffi_leak_tracker: Runs tests for package:ffi_leak_tracker
    • test_filepicker_windows: Runs tests for package:filepicker_windows
    • test_generator: Runs tests for package:generator
    • test_win32: Runs tests for package:win32
    • test_win32_clipboard: Runs tests for package:win32_clipboard
    • test_win32_gamepad: Runs tests for package:win32_gamepad
    • test_win32_registry: Runs tests for package:win32_registry
    • test_win32_runner: Runs tests for package:win32_runner
    • test_winmd: Runs tests for package:winmd
  • Commit-msg Hook:

๐Ÿ”„ Creating a Pull Requestโ€‹

After committing your changes, push them to your fork and create a pull request. When you open a pull request, tests will run automatically, and our maintainers will review it.

Please use the pull request template to provide details about your changes, ensuring a smoother review process.

Thank you for contributing to package:win32! ๐ŸŽ‰