-
Notifications
You must be signed in to change notification settings - Fork 94
refactor: use std::path::absolute
instead of canonicalize + strip_extended_path_prefix
#462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
make `utils` module private and re-export only the required `pub` functions refactor cargo-wdk and add tests accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @svasista-ms.
I want to suggest that it's better to avoid unrelated changes or those not directly related to the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one more comment. After that I'll approve
canonicalize + strip_extended_path_prefix
with path::absolute
std::path::absolute
instead of canonicalize + strip_extended_path_prefix
fix comment in cli.rs
3f3ed5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the codebase to use the standard library's std::path::absolute
function instead of the previous combination of std::fs::canonicalize
and a custom strip_extended_path_prefix
helper function for path normalization on Windows.
Key changes include:
- Replace canonicalize + strip_extended_path_prefix with std::path::absolute for syntactic path absolutization
- Remove custom PathExt trait and related path utility code
- Add explicit error handling for extended/verbatim paths in cargo wdk new command
- Move TwoPartVersion type and related utilities from utils module to lib module
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
crates/wdk-build/src/utils.rs | Removes PathExt trait, strip_extended_path_prefix utilities, and TwoPartVersion code; changes find_max_version_in_directory visibility |
crates/wdk-build/src/lib.rs | Adds TwoPartVersion type and utilities; replaces canonicalize+strip calls with std::path::absolute |
crates/wdk-build/src/cargo_make.rs | Updates path handling to use std::path::absolute instead of canonicalize+strip |
crates/cargo-wdk/src/providers/mod.rs | Removes PathCanonicalizationError variant |
crates/cargo-wdk/src/providers/fs.rs | Removes canonicalize_path method from Fs provider |
crates/cargo-wdk/src/cli.rs | Adds explicit check and error for extended/verbatim paths in new command |
crates/cargo-wdk/src/actions/mod.rs | Adds PartialEq + Eq derives to Profile and TargetArch enums |
crates/cargo-wdk/src/actions/build/tests.rs | Removes path canonicalization expectations from test mocks |
crates/cargo-wdk/src/actions/build/package_task.rs | Adds validation for absolute paths and comprehensive test coverage |
crates/cargo-wdk/src/actions/build/mod.rs | Updates to use std::path::absolute and removes fs canonicalization calls |
crates/cargo-wdk/src/actions/build/error.rs | Adds io::Error variant to BuildActionError |
crates/cargo-wdk/src/actions/build/build_task.rs | Simplifies constructor to use absolute path assertion instead of canonicalization |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
add assert for command_exec
Closes #367, closes #479
We previously combined
std::fs::canonicalize
with a custom strip_extended_path_prefix helper to normalize Windows paths and remove the extended (verbatim) prefix (?). Issue #367 tracked replacing this logic with a standard library alternative,std::path::absolute
.Motivation
User Impact:
Slight behavior change in
cargo wdk new
: verbatim (extended) paths now return a clear error instead of being silently normalized. (Issue #481 was created to add support for verbatim, extended paths)