-
Notifications
You must be signed in to change notification settings - Fork 5k
FileSystemGlobbing.Matcher is not matching '**/*' #44767
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
Comments
Tagging subscribers to this area: @maryamariyan Issue Details
|
I doubt the regression is from a change within FileSystemGlobbing itself specifically, as I see no recent changes there from .NET 5 Preview 7. Will dig into its references too to see what changed. |
cc: @carlossanlop @jozkee |
@JoeRobich To confirm regression, I also ran the same sample code on netcoreapp3.0 using 3.0 version of M.E.FileSyetemGlobbing on both mac and windows, and see the same result (False/False on windows and True/False on mac). Perhaps not a regression? Am I missing something? |
@maryamariyan Sorry, after looking at the implementation of This explains why the behavior in dotnet-format was broken, since it isn't unreasonable for users to run formatting on code outside of the current working directory. Do you have any suggestions for how we can use this library for matching file names to patterns without the requirement that all file paths be beneath the current working directory? |
@JoeRobich your path's format should match the expected one for the current OS. If you are using the following path, which you shared, in a Unix environment: var fakeWindowsPath = "C:\\This\\is\\a\\nested\\windows-like\\path\\somefile.cs"; Then you will not get the same result you would get in Windows, because:
carlos@carlospc:~/tmp$ mkdir "my\folder"
carlos@carlospc:~/tmp$ ls -l
total 4
drwxr-xr-x 2 carlos carlos 4096 Nov 18 13:11 'my\folder'
carlos@carlospc:~/tmp$ rmdir "my\folder"
carlos@carlospc:~/tmp$ mkdir "my:folder"
carlos@carlospc:~/tmp$ ls -l
total 4
drwxr-xr-x 2 carlos carlos 4096 Nov 18 13:12 my:folder
On the other hand, Windows is a bit more flexible when you pass it a Unix path. For example, the following path, which you shared, if you use it in a Windows machine: var fakeUnixPath = "/This/is/a/nested/unix-like/path/somefile.cs"; Then Windows will:
So my suggestions are:
Hope that helps. Please let me know if you have any more questions. |
@carlossanlop Sorry, I don't have a problem with the normalization of paths. Our paths are full paths and correct for the OS. The issue is that if the path doesn't begin with the current working directory the Matcher will not produce matches (https://github.com/dotnet/runtime/blob/master/src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/InMemoryDirectoryInfo.cs#L86). If you can give guidance on how to work around this current working directory requirement it would be appreciated. |
Just to reconfirm @JoeRobich this is not a regression right? |
@maryamariyan It appears to not be a regression. |
I think that's not true, absolute paths as the one you mention,
MatcherExtensions.Match method can receive a @JoeRobich are you able to provide a root directory to the method to workaround this? |
I also found that there is a bug if you use a root directory that end with a separator, such as runtime/src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/InMemoryDirectoryInfo.cs Lines 122 to 123 in 65d42f0
Files won't match |
@jozkee the only reason the windows style path matched was because the path normalization on a unix like environment prepends the current directory. The Thanks for suggesting the overload. I agree that the bug you mentioned is blocking our ability to simply use |
Fixed in #45139 |
Thanks @jozkee! I will give this a try tomorrow. |
Fixed by #45139, closing |
Description
In dotnet/format we use the FileSystemGlobbing.Matcher to allow users the ability to filter the files that are being formatted. We started getting reports that dotnet/format was not formatting the expected files. While troubleshooting it became apparent that the Matcher was no longer matching paths as expected.
Configuration
This simple console app tries to match different path strings using the "Any files in any subdirectory" pattern.
TestConsole.csproj:
Program.cs:
Output running on MacOS:
Output running on Windows:
Regression?
This had worked at least as late as .NET 5 Preview 7.
The text was updated successfully, but these errors were encountered: