Skip to content

Simplify how extension code for windows crate works#3110

Merged
kennykerr merged 12 commits intomicrosoft:masterfrom
sivadeilra:user/ardavis/includes
Jun 18, 2024
Merged

Simplify how extension code for windows crate works#3110
kennykerr merged 12 commits intomicrosoft:masterfrom
sivadeilra:user/ardavis/includes

Conversation

@sivadeilra
Copy link
Copy Markdown
Collaborator

This reduces the complexity between windows-bindgen and windows. This makes it much easier to write "extension" code for the windows crate, by reducing the number of places in the code you need to touch.

This also removes the need to run cargo run -p tool_bindings whenever you touch the extension code for the windows crate. You don't need to update the bindings if you're just working on the extensions. Instead, you just edit extension code, like normal Rust code.

The extension code has moved from .../bindgen/src/rust/extensions to windows/src/extensions. This puts the code much closer to the code that it extends. Also, the extension code is now just a normal set of Rust modules. This makes the language service (Rust Analyzer) work more naturally; refactoring and go-to-definition and such simply work, rather than pointing to source files that were generated by bindgen.

Since the extension code is now just normal Rust modules, I had to add a handful of use crate::Foo::Bar::BAZ; imports to each extension source file. This seems like a good thing; more signs that this is just normal code.

I've staged the changes in a set of commits. You can see how each piece of extension logic was moved, or you can view all the changes as a single set. The last commit applies rustfmt to the extension code. This wasn't happening before, since those files were not part of any module tree, so cargo fmt overlooked them.

dpaoliello
dpaoliello previously approved these changes Jun 17, 2024
Copy link
Copy Markdown
Collaborator

@dpaoliello dpaoliello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! Nice to see a ton of duplicated code and hardcoded lists disappear.

Comment thread crates/libs/bindgen/src/rust/extensions/mod.rs Outdated
Copy link
Copy Markdown
Collaborator

@kennykerr kennykerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

@kennykerr kennykerr merged commit d33dcf7 into microsoft:master Jun 18, 2024
@sivadeilra sivadeilra deleted the user/ardavis/includes branch June 18, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants