-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix MakeRelative regression in v16.10 #6508
Conversation
|
Assert.Equal(@"def\", FileUtilities.MakeRelative(@"c:\abc\", @"c:\abc\def\")); | ||
Assert.Equal(@"..\", FileUtilities.MakeRelative(@"c:\abc\def\xyz\", @"c:\abc\def\")); | ||
Assert.Equal(@"..\ttt\", FileUtilities.MakeRelative(@"c:\abc\def\xyz\", @"c:\abc\def\ttt\")); | ||
Assert.Equal(@".", FileUtilities.MakeRelative(@"c:\abc\def\", @"c:\abc\def\")); |
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.
There is opportunity to extend test coverage for combination of file+directory and directory+file.
/* Directory + File */
Assert.Equal(@"def", FileUtilities.MakeRelative(@"c:\abc\", @"c:\abc\def"));
Assert.Equal(@"..\..\def", FileUtilities.MakeRelative(@c:\abc\def\xyz\", @"c:\abc\def"));
Assert.Equal(@"..\ghi", FileUtilities.MakeRelative(@c:\abc\def\xyz\", @"c:\abc\def\ghi"));
Assert.Equal(@"..\def", FileUtilities.MakeRelative(@c:\abc\def\", @"c:\abc\def"));
/* File + Directory */
Assert.Equal(@"def\", FileUtilities.MakeRelative(@c:\abc", @"c:\abc\def\"));
Assert.Equal(@"..\", FileUtilities.MakeRelative(@c:\abc\def\xyz", @"c:\abc\def\"));
Assert.Equal(@"..\ghi\", FileUtilities.MakeRelative(@c:\abc\def\xyz", @"c:\abc\def\ghi\"));
Assert.Equal(@"", FileUtilities.MakeRelative(@c:\abc\def", @"c:\abc\def\"));
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.
Good suggestion - have added more tests
Hmmm.. didn't expect all those commits to be added to the pull request when changing the base branch. And the checks failed too - changing back... |
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.
Looks good! I think I know when this came in—the original uri-based implementation failed tests in the installer repo, for some reason. This version passed those tests and was a bit faster—but also inadvertently changed our behavior with slashes. I don't see why that would be necessary to maintain, so I think this is a good change.
Oh, and also: 🙂 Is there any reason to keep #6504 around anymore? |
Co-authored-by: Forgind <Forgind@users.noreply.github.com>
The other pr was started by @pmisik - it looks like he has pulled my changes into that and rebased to v16.10 - but it doesn't build for some reason. I really should have based this pr on v16.10 as the fix is needed to fix major dependency issues. Will attempt to base it on v16.10 now - do I need to rebase the source before using the new update to base branch feature? |
Have created a new PR #6513 with the same changes squashed and rebased onto vs16.10 branch |
Fixes #6493
Replaces PR by @pmisik : #6504
Context
Recent change to MakeRelative function was causing existing targets to fail. The change removed the backslash from the end of paths. This change causes the function to revert to the previous behaviour.
Changes Made
FileUtilities.cs updated
Testing
Added unit tests to FileUtilities_Tests.cs.