-
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
Combine rootDir with relative file names #94528
Conversation
Added When you commit this breaking change:
Tagging @dotnet/compat for awareness of the breaking change. |
Tagging subscribers to this area: @dotnet/area-extensions-filesystem Issue DetailsFixes #50648 Using
However, this is a (massive?) breaking change as there's already a lot of tests showing that filenames are relative to CWD and not to rootDir, and in the wild, there will be most likely use cases that depend in this bug (need to check).
|
This looks like a good change to make, and it's valuable to make the change very early in .NET 9. Given the potential breaking-change impact though, we might need to produce a qualified assessment of risk and probably even find ways to alert users this is coming. We can partner with the @dotnet/compat folks to study call sites, identify some places that might be depending on this behavior, and determine if this is something we need to phase in with a compat switch. We might even discover a scenario where this behavior could not be opted into. If we see a lot of risk, we might even want to explore an analyzer to produce a warning on call sites. @jozkee I'll follow up with you offline. In the meantime, I'll mark this PR as
NO-MERGE
|
I found one usage of the affected overload in our first party data. It is for smoke tests on dotnet/installer. This leads me to believe that most people use the overloads that don’t take a rootDir, those use the cwd as rootDir inplicitly. I’ll try to visualize the breaking change: string rootDir = "dir1";
string[] files = ["dir1/test.0", "dir1/subdir/test.1", "dir2/test.2"];
PatternMatchingResult result = new Matcher().AddInclude("**/*").Match(rootDir, files);
Console.WriteLine(string.Join(", ", result.Files.Select(x => x.Path))); Because both args are treated as relative to the cwd. In order to get a similar (but not same) output as prior you need to change the code to something like the following: string rootDir = "dir1";
string[] files = ["dir1/test.0", "dir1/subdir/test.1", "dir2/test.2"];
-PatternMatchingResult result = new Matcher().AddInclude("**/*").Match(rootDir, files);
+PatternMatchingResult result = new Matcher().AddInclude("dir1/**/*").Match(rootDir, files);
Console.WriteLine(string.Join(", ", result.Files.Select(x => x.Path)));
// prints
// dir1/test.0
// dir1/subdir/test.1 @ericstj would be good to send this to the VMR in order to validate that the dotnet/installer test doesn't break with this change? |
Good find, @jozkee! Is there a way to update the calling code before the change goes through that would allow the calling code to function as desired both now and after the breaking change goes through? If so, we could go ahead and update dotnet/installer so that as the breaking change goes through the tests will keep passing. If not, then we might want to consider disabling that test until the change flows through and then re-enabling it. |
@jeffhandley I can verify it, just need to find out how to run the smoke tests in dotnet/installer. |
How is
Not necessary - it wouldn't be running these tests (nor is it accepting commits yet). You'd just need to watch this change flowing up to installer then fix up the test when it hits it. |
Because now
While previously it contained the following, because |
I see - might be better to not reuse the name - since the use of |
Breaking change doc. created: dotnet/docs#39189 |
I think this change caused another unintended breaking change. Filed: #100762 |
Fixes #50648
Using
Path.GetFullPath
on relative file names causes that the in-memoryMatcher.Match
to treat files as relative to the CWD blocking scenarios that are using a rootDir in a different drive as the one discussed in #50648. We should combine the rootDir with the relative file names instead. This is also what's described in the documentation.However, this is a (massive?) breaking change as there's already a lot of tests showing that filenames are relative to CWD and not to rootDir, and in the wild, there will be most likely use cases that depend in this bug (need to check).