-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Windows] Fix Directory.GetFiles() returning paths with trailing spaces or periods when directory has trailing spaces or periods #121038
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
Closed
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
654d046
Initial plan
Copilot 5e3bf96
Fix Directory.GetFiles() to not return file paths with trailing spaces
Copilot 2a5b37c
Merge branch 'main' into copilot/fix-directory-getfiles-space-issue
jkotas e56dc76
Improve fix to preserve trailing separators while removing trailing s…
Copilot 63f7b83
Revert to original simple fix and update test to match issue scenario
Copilot 908c56c
Update src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/…
jkotas a9c933b
Apply suggestions from code review
jkotas f8ffe2a
Update src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/…
jkotas 5457f04
Move fix to FileSystemEnumerableFactory and add OriginalRootDirectory…
Copilot e652606
Also trim trailing periods along with trailing spaces
Copilot 9857edb
Update src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/…
jkotas 5e3dbba
Update src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/…
jkotas dc2eeea
Delete OriginalRootDirectoryPreservesTrailingSpaces test
Copilot 2bf80fc
Use WindowsTrailingProblematicFileNames for OriginalRootDirectory test
Copilot e66a19e
Make EnumerateDirectoryWithTrailingSpacePeriod Windows-specific and s…
Copilot 89b835a
Fix OriginalRootDirectoryPreservesInput test to use trailing separato…
Copilot 014ce4b
Skip trimming for extended path syntax (\\?\ and \\.\)
Copilot ac9a252
Enable EnumerateDirectoryWithTrailingSpacePeriod test on all platforms
Copilot 5eb1705
Fix build error and make test Windows-specific
Copilot 4e02f44
Make trailing space/period trimming Windows-specific with #if WINDOWS
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
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.
@copilot How about 3 or more dots like "..."? Is that case handled correctly?
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.
Yes, "..." is handled correctly. The code uses
TrimEnd(' ', '.')which would trim all trailing periods and spaces, resulting in an empty string. However, we checkif (trimmed.Length > 0)before applying the trim, so paths like "...", "..", and "." are not modified - they remain as-is. This preserves special directory references while still fixing the issue. Commit: 5eb1705