diff --git a/Sharpmake.UnitTests/UtilTest.cs b/Sharpmake.UnitTests/UtilTest.cs index df2405c99..e2a899ce4 100644 --- a/Sharpmake.UnitTests/UtilTest.cs +++ b/Sharpmake.UnitTests/UtilTest.cs @@ -62,8 +62,6 @@ public void LeavesEmptyStringsUntouched() public void LeavesVariablesUntouched() { string expectedResult = "$(Console_SdkPackagesRoot)"; - if (!Util.IsRunningInMono()) - expectedResult = expectedResult.ToLower(); Assert.That(Util.PathMakeStandard("$(Console_SdkPackagesRoot)"), Is.EqualTo(expectedResult)); } @@ -71,8 +69,6 @@ public void LeavesVariablesUntouched() public void ProcessesPathWithTrailingBackslash() { string expectedResult = Path.Combine("rd", "project", "dev", "projects", "sharpmake", "..", "..", "extern", "Geometrics"); - if (!Util.IsRunningInMono()) - expectedResult = expectedResult.ToLower(); Assert.That(Util.PathMakeStandard(@"rd\project\dev\projects\sharpmake\..\..\extern\Geometrics\"), Is.EqualTo(expectedResult)); } @@ -80,8 +76,6 @@ public void ProcessesPathWithTrailingBackslash() public void ProcessesPathWithTrailingBackslashAndADot() { var expectedResult = Path.Combine("rd", "project", "dev", "projects", "sharpmake", "..", "..", "extern", "Microsoft.CNG", "Lib"); - if (!Util.IsRunningInMono()) - expectedResult = expectedResult.ToLower(); Assert.That(Util.PathMakeStandard(@"rd\project\dev\projects\sharpmake\..\..\extern\Microsoft.CNG\Lib\"), Is.EqualTo(expectedResult)); } @@ -89,8 +83,6 @@ public void ProcessesPathWithTrailingBackslashAndADot() public void ProcessesPathWithMultipleTrailingBackslashes() { var expectedResult = Path.Combine("rd", "project", "dev", "projects", "sharpmake", "..", "..", "extern", "Microsoft.CNG", "Lib"); - if (!Util.IsRunningInMono()) - expectedResult = expectedResult.ToLower(); Assert.That(Util.PathMakeStandard(@"rd\project\dev\projects\sharpmake\..\..\extern\Microsoft.CNG\Lib\\\"), Is.EqualTo(expectedResult)); } @@ -108,9 +100,6 @@ public void ProcessesWithAListAsArgument() }; var expectedList = listString; - if (!Util.IsRunningInMono()) - expectedList = expectedList.Select((p) => p.ToLower()).ToList(); - Util.PathMakeStandard(listString); Assert.AreEqual(expectedList, listString); @@ -753,7 +742,7 @@ public void CanBeComputedFromOutputPath() var referenceFileFullPath = outputFileFullPath.ReplaceHeadPath(outputPath, referencePath); Assert.That(referenceFileFullPath, Is.EqualTo( - Util.PathMakeStandard(@"F:\OnePath\With\Reference\with\a\file.cs", false))); + Util.PathMakeStandard(@"F:\OnePath\With\Reference\with\a\file.cs"))); } [Test] @@ -766,7 +755,7 @@ public void IsCaseInsensitiveButPreservesCase() var referenceFileFullPath = outputFileFullPath.ReplaceHeadPath(outputPath, referencePath); Assert.That(referenceFileFullPath, Is.EqualTo( - Util.PathMakeStandard(@"F:\OnePath\with\Reference\with\a\File.cs", false))); + Util.PathMakeStandard(@"F:\OnePath\with\Reference\with\a\File.cs"))); } [Test] @@ -779,7 +768,7 @@ public void AcceptsOutputPathWithoutTrailingSlash() var referenceFileFullPath = outputFileFullPath.ReplaceHeadPath(outputPath, referencePath); Assert.That(referenceFileFullPath, Is.EqualTo( - Util.PathMakeStandard(@"F:\OnePath\With\Reference\with\a\file.cs", false))); + Util.PathMakeStandard(@"F:\OnePath\With\Reference\with\a\file.cs"))); } } @@ -1000,7 +989,7 @@ public void PathGetAbsoluteStringsReturnList() string filename = Path.GetFileName(mockPath); string stringsSource = Path.GetDirectoryName(mockPath); - Assert.AreEqual(Path.Combine(stringsSource.ToLower(), filename), Util.PathGetAbsolute(stringsSource, new Strings(filename))[0]); + Assert.AreEqual(Path.Combine(stringsSource, filename), Util.PathGetAbsolute(stringsSource, new Strings(filename))[0]); File.Delete(mockPath); } @@ -1015,7 +1004,7 @@ public void PathGetAbsoluteStringsReturnString() var separator = Path.DirectorySeparatorChar; string stringsSource = mockPath.Substring(0, mockPath.IndexOf(separator)); string stringsDest = mockPath.Substring(mockPath.IndexOf(separator, mockPath.IndexOf(separator) + 1)); - string expectedOutputPath = stringsSource.ToLower() + stringsDest; + string expectedOutputPath = stringsSource + stringsDest; //v Assert.AreEqual(expectedOutputPath, Util.PathGetAbsolute(stringsSource, stringsDest)); @@ -1032,7 +1021,6 @@ public void ResolvePathString() Strings paths = new Strings(Path.GetDirectoryName(mockPath)); string root = mockPath.Substring(0, mockPath.IndexOf(Path.DirectorySeparatorChar)); Strings expectedOutputPath = new Strings(paths.Select((p) => Path.Combine(root, p))); - expectedOutputPath.ToLower(); Util.ResolvePath(root, ref paths); @@ -1057,7 +1045,7 @@ public void ResolvePathOrderableString() mockPath3.Substring(mockPath3.IndexOf(Path.DirectorySeparatorChar)), }; string root = mockPath1.Substring(0, mockPath1.IndexOf(Path.DirectorySeparatorChar)); - OrderableStrings expectedOutputPath = new OrderableStrings(paths.Select((p) => (root + p).ToLower())); + OrderableStrings expectedOutputPath = new OrderableStrings(paths.Select((p) => (root + p))); Util.ResolvePath(root, ref paths); expectedOutputPath.Sort(); @@ -1114,8 +1102,8 @@ public void PathGetRelativeOrderableStrings() Util.PathMakeStandard(stringsDest); OrderableStrings listResult = Util.PathGetRelative(stringsSource, stringsDest, false); - Assert.AreEqual(Util.PathMakeStandard(@"..\Sharpmake.Generators\Generic", !Util.IsRunningInMono()), listResult[0]); - Assert.AreEqual(Util.PathMakeStandard(@"subdir\test.txt", !Util.IsRunningInMono()), listResult[1]); + Assert.AreEqual(Util.PathMakeStandard(@"..\Sharpmake.Generators\Generic"), listResult[0]); + Assert.AreEqual(Util.PathMakeStandard(@"subdir\test.txt"), listResult[1]); Assert.AreEqual("test2.txt", listResult[2]); } @@ -1192,11 +1180,11 @@ public void GetConvertedRelativePathRoot() var root = @"C:\SharpMake\sharpmake\Sharpmake.Application\Properties"; var newRelativeToFullPath = ""; - Assert.AreEqual(Path.Combine(absolutePath.ToLower(), fileName), Util.GetConvertedRelativePath(absolutePath, fileName, newRelativeToFullPath, false, null)); + Assert.AreEqual(Path.Combine(absolutePath, fileName), Util.GetConvertedRelativePath(absolutePath, fileName, newRelativeToFullPath, false, null)); Assert.AreEqual(mockPath, Util.GetConvertedRelativePath(absolutePath, mockPath, newRelativeToFullPath, false, root)); - Assert.AreEqual(Path.Combine(absolutePath.ToLower(), fileName), Util.GetConvertedRelativePath(absolutePath, fileName, newRelativeToFullPath, false, "")); + Assert.AreEqual(Path.Combine(absolutePath, fileName), Util.GetConvertedRelativePath(absolutePath, fileName, newRelativeToFullPath, false, "")); Assert.AreEqual(absolutePath, Util.GetConvertedRelativePath(absolutePath, null, newRelativeToFullPath, false, null)); - Assert.AreEqual(Path.Combine(root.ToLower(), Path.GetTempPath()), Util.GetConvertedRelativePath(root, Path.GetTempPath(), newRelativeToFullPath, false, null)); + Assert.AreEqual(Path.Combine(root, Path.GetTempPath()), Util.GetConvertedRelativePath(root, Path.GetTempPath(), newRelativeToFullPath, false, null)); File.Delete(mockPath); } diff --git a/Sharpmake/PathUtil.cs b/Sharpmake/PathUtil.cs index fa33c961a..fb90355a3 100644 --- a/Sharpmake/PathUtil.cs +++ b/Sharpmake/PathUtil.cs @@ -40,16 +40,10 @@ public static void PathMakeStandard(IList paths) } public static string PathMakeStandard(string path) - { - return PathMakeStandard(path, !Util.IsRunningOnUnix()); - } - - public static string PathMakeStandard(string path, bool forceToLower) { // cleanup the path by replacing the other separator by the correct one for this OS // then trim every trailing separators - var standardPath = path.Replace(OtherSeparator, Path.DirectorySeparatorChar).TrimEnd(Path.DirectorySeparatorChar); - return forceToLower ? standardPath.ToLower() : standardPath; + return path.Replace(OtherSeparator, Path.DirectorySeparatorChar).TrimEnd(Path.DirectorySeparatorChar); } public static string EnsureTrailingSeparator(string path) @@ -797,9 +791,9 @@ internal static string ConvertToMountedUnixPath(string path) public static string ReplaceHeadPath(this string fullInputPath, string inputHeadPath, string replacementHeadPath) { // Normalize paths before comparing and combining them, to prevent false mismatch between '\\' and '/'. - fullInputPath = Util.PathMakeStandard(fullInputPath, false); - inputHeadPath = Util.PathMakeStandard(inputHeadPath, false); - replacementHeadPath = Util.PathMakeStandard(replacementHeadPath, false); + fullInputPath = PathMakeStandard(fullInputPath); + inputHeadPath = PathMakeStandard(inputHeadPath); + replacementHeadPath = PathMakeStandard(replacementHeadPath); inputHeadPath = EnsureTrailingSeparator(inputHeadPath);