-
-
Notifications
You must be signed in to change notification settings - Fork 741
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
Make FilePath and DirectoryPath comparable by value #3075
Comments
Important to think about is that any string comparison would need to take filesystem in consideration. |
That's an interesting thought. What situation(s) do you think the user can create instances of I did some initial tests based on the assumption that we would implement Some initial tests seem to indicate that
The only situation that might seem a little odd at first would be comparing, for example, a build.cakevar relativeFilePath1 = FilePath.FromString("./MyProject/MyApp.csproj");
var relativeFilePath2 = FilePath.FromString(".\\MyProject\\MyApp.csproj");
var absoluteFilePath1 = MakeAbsolute(FilePath.FromString("./MyProject/MyApp.csproj"));
var absoluteFilePath2 = MakeAbsolute(FilePath.FromString(".\\MyProject\\MyApp.csproj"));
var absoluteFilePath3 = FilePath.FromString("C:/augustoproiete/cake/1.0.0-rc0003/MyProject/MyApp.csproj");
var absoluteFilePath4 = FilePath.FromString("C:\\augustoproiete\\cake\\1.0.0-rc0003\\MyProject\\MyApp.csproj");
var absoluteFilePath5 = FilePath.FromString("/Users/augustoproiete/cake/1.0.0-rc0003/MyProject/MyApp.csproj");
var absoluteFilePath6 = FilePath.FromString("\\Users\\augustoproiete\\cake\\1.0.0-rc0003\\MyProject\\MyApp.csproj");
var relativeDirectoryPath1 = DirectoryPath.FromString("./MyProject/bin");
var relativeDirectoryPath2 = DirectoryPath.FromString(".\\MyProject\\bin");
var absoluteDirectoryPath1 = MakeAbsolute(DirectoryPath.FromString("./MyProject/bin"));
var absoluteDirectoryPath2 = MakeAbsolute(DirectoryPath.FromString(".\\MyProject\\bin"));
var absoluteDirectoryPath3 = DirectoryPath.FromString("C:/augustoproiete/cake/1.0.0-rc0003/MyProject/bin");
var absoluteDirectoryPath4 = DirectoryPath.FromString("C:\\augustoproiete\\cake\\1.0.0-rc0003\\MyProject\\bin");
var absoluteDirectoryPath5 = DirectoryPath.FromString("/Users/augustoproiete/cake/1.0.0-rc0003/MyProject/bin");
var absoluteDirectoryPath6 = DirectoryPath.FromString("\\Users\\augustoproiete\\cake\\1.0.0-rc0003\\MyProject\\bin");
Information("Running On: {0}", Context.Environment.Platform.Family);
Information("---");
Information("relativeFilePath1: [{0}]", relativeFilePath1.FullPath);
Information("relativeFilePath2: [{0}]", relativeFilePath2.FullPath);
Information("");
Information("absoluteFilePath1: [{0}]", absoluteFilePath1.FullPath);
Information("absoluteFilePath2: [{0}]", absoluteFilePath2.FullPath);
Information("absoluteFilePath3: [{0}]", absoluteFilePath3.FullPath);
Information("absoluteFilePath4: [{0}]", absoluteFilePath4.FullPath);
Information("absoluteFilePath5: [{0}]", absoluteFilePath5.FullPath);
Information("absoluteFilePath6: [{0}]", absoluteFilePath6.FullPath);
Information("");
Information("relativeDirectoryPath1: [{0}]", relativeDirectoryPath1.FullPath);
Information("relativeDirectoryPath2: [{0}]", relativeDirectoryPath2.FullPath);
Information("");
Information("absoluteDirectoryPath1: [{0}]", absoluteDirectoryPath1.FullPath);
Information("absoluteDirectoryPath2: [{0}]", absoluteDirectoryPath2.FullPath);
Information("absoluteDirectoryPath3: [{0}]", absoluteDirectoryPath3.FullPath);
Information("absoluteDirectoryPath4: [{0}]", absoluteDirectoryPath4.FullPath);
Information("absoluteDirectoryPath5: [{0}]", absoluteDirectoryPath5.FullPath);
Information("absoluteDirectoryPath6: [{0}]", absoluteDirectoryPath6.FullPath);
Information(""); |
Casing would be one thing. On Windows files are case insensitive. |
Make sense. Perhaps we can use a similar approach to Maybe add an exception when comparing paths that are rooted with drive letter to always be case-insensitive (even if not on Windows) - also similar approach to |
I can take this task. I did some investigation and found this PathComparer class, it already has the platform dependant comparasion you discussed previously. Should I try to reuse its logic when implementing |
PathComparer is designed for this scenario. |
Noted. I will take care of this one then :) |
🎉 This issue has been resolved in version v2.0.0 🎉 The release is available on: Your GitReleaseManager bot 📦🚀 |
Currently
FilePath
andDirectoryPath
comparisons are done by reference, and identical paths in different instances are considered to be different.Example
What You Are Seeing?
What is Expected?
What version of Cake are you using?
1.0.0-rc0003
The text was updated successfully, but these errors were encountered: