-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
FileSystemEventArgs.FullPath does not return a fully qualified path #62606
Comments
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsDescriptionAs per the documentation https://docs.microsoft.com/en-us/dotnet/api/system.io.filesystemeventargs.fullpath?view=net-6.0 the When used in conjunction with FileSystemWatcher it is possible for the path to be relative: https://github.com/dotnet/runtime/blob/main/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs#L260 Reproduction StepsRepro code:
Expected behaviorOutput should be: Actual behaviorCurrent output: Regression?No response Known WorkaroundsUsing
Configuration.Net 6.0 Other informationNo response
|
cc @jozkee |
This would require a breaking change on |
Hi @jozkee. Can I take this issue? |
@slask Yes, let me assign you. Thanks! |
Gets the fully qualified path after combining the directory and name part as per the thread discussion. Also added and updated tests for the new change. Fix dotnet#62606
To be consistent with new behavior of FullPath from FileSystemEventArgs same change was applied for RenamedEventArgs including updated tests. Fix dotnet#62606
In the context of using an actual full path which can vary on Unix vs Windows Fix dotnet#62606
Adjusted unit tests to match the new logic. Fix dotnet#62606
The previous buggy implementation of RenamedEventArgs produced a convenient side-effect for PhysicalFilesWatcher. Without the trailing slash adde by RenamedEventArgs the root was longer than the fullPath by a trailing slash. Fix dotnet#62606
Implemented most of the code review suggestions. Fix dotnet#62606
Also made unit tests more focused by removing needless asserts from the tests Fix dotnet#62606
Reverted the changes to PhysicalFilesWatcher and added back the trailing separator behavior as per code review suggestion Fix dotnet#62606
Linking docs issue dotnet/docs#27916 |
As per code review suggestions. Fix dotnet#62606
Pipeline retrigger. Some pipelines timed out, most probably transient issues. Fix dotnet#62606
* FullPath property now returns fully qualified path Gets the fully qualified path after combining the directory and name part as per the thread discussion. Also added and updated tests for the new change. Fix #62606 * OldFullPath returns fully qualified path To be consistent with new behavior of FullPath from FileSystemEventArgs same change was applied for RenamedEventArgs including updated tests. Fix #62606 * Marked some test cases as Windows OS specific In the context of using an actual full path which can vary on Unix vs Windows Fix #62606 * Using Path.Join instead of the custom Combine Adjusted unit tests to match the new logic. Fix #62606 * Account for corner case when fullPath matches root The previous buggy implementation of RenamedEventArgs produced a convenient side-effect for PhysicalFilesWatcher. Without the trailing slash adde by RenamedEventArgs the root was longer than the fullPath by a trailing slash. Fix #62606 * Handle relative paths from CWD in given drive Fix #62606 * Clearly separated unix and windows test cases Implemented most of the code review suggestions. Fix #62606 * Use EnsureTrailingSeparator instead of custom code Also made unit tests more focused by removing needless asserts from the tests Fix #62606 * Keeping the old behavior with trailing separator Reverted the changes to PhysicalFilesWatcher and added back the trailing separator behavior as per code review suggestion Fix #62606 * Used Path.Combien vs PathInternalEnsureSeparator As per code review suggestions. Fix #62606 * Added blank line for readability Pipeline retrigger. Some pipelines timed out, most probably transient issues. Fix #62606
After fixing #68566 with #68582, which was addressing a regression caused by #63051, which fixed this issue, I've reconsidered this original issue further. I think we should revert both #68582 and #63051 and return The regression that was reported involved using an empty directory name, and it was relying on I'm going to submit a PR that reverts both #63051 and #68582, but leaves the additional tests in place, adapted to match the previous behavior. |
Description
As per the documentation https://docs.microsoft.com/en-us/dotnet/api/system.io.filesystemeventargs.fullpath?view=net-6.0 the
FullPath
property should return a fully qualified path. However it appears the constructor forFileSystemEventArgs
assumes the directory passed in is fully qualified: https://github.com/dotnet/runtime/blob/main/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemEventArgs.cs#L22When used in conjunction with FileSystemWatcher it is possible for the path to be relative: https://github.com/dotnet/runtime/blob/main/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs#L260
Reproduction Steps
Repro code:
I created the following dir structure on my machine:
C:\foo\bar\footest.txt
Set the working directory to be
C:\foo
Run the program and then modify
footest.txt
to trigger a changed event.Expected behavior
Output should be:
Changed: C:\foo\bar\footest.txt
Actual behavior
Current output:
Changed: bar\footest.txt
Regression?
No response
Known Workarounds
Using
Path.GetFullPath
to fetch the fully qualified pathConfiguration
.Net 6.0
Windows 10 x64
After looking at the source I believe that this is not unique to Windows
Other information
No response
The text was updated successfully, but these errors were encountered: