refactor: use std::path::absolute instead of canonicalize + strip_extended_path_prefix#462
Merged
gurry merged 20 commits intomicrosoft:mainfrom Sep 11, 2025
Merged
Conversation
make `utils` module private and re-export only the required `pub` functions refactor cargo-wdk and add tests accordingly
gurry
previously approved these changes
Aug 14, 2025
Contributor
gurry
left a comment
There was a problem hiding this comment.
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.
gurry
reviewed
Aug 15, 2025
wmmc88
reviewed
Aug 15, 2025
wmmc88
reviewed
Aug 15, 2025
gurry
reviewed
Aug 20, 2025
fix comment in cli.rs
3f3ed5a
Contributor
There was a problem hiding this comment.
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.
gurry
reviewed
Aug 29, 2025
gurry
previously approved these changes
Sep 2, 2025
gurry
reviewed
Sep 10, 2025
add assert for command_exec
wmmc88
reviewed
Sep 11, 2025
wmmc88
approved these changes
Sep 11, 2025
gurry
approved these changes
Sep 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #367 and #479
We previously combined
std::fs::canonicalizewith 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)