From c6ed21e67b40bd636df845e166a70e0a6abdbd57 Mon Sep 17 00:00:00 2001 From: Michiel Oda Date: Tue, 10 Feb 2026 13:49:50 +0100 Subject: [PATCH 1/2] Path - Fix NullReferenceException that occurs when running on Ubuntu --- FileSystem/PathIOLinux.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/FileSystem/PathIOLinux.cs b/FileSystem/PathIOLinux.cs index fad8f6f..e9b5094 100644 --- a/FileSystem/PathIOLinux.cs +++ b/FileSystem/PathIOLinux.cs @@ -200,13 +200,13 @@ private static string SeparatorWrapper(Func pathMethod, string p var unixResult = pathMethod(convertedToUnix); - if (returnWithRoot) + if (returnWithRoot && unixResult != null) { finalResult = removedWindowsRoot[0] + ":" + unixResult.Replace(LinuxSeparator, WindowsSeparator); } else { - finalResult = unixResult.Replace(LinuxSeparator, WindowsSeparator); + finalResult = unixResult?.Replace(LinuxSeparator, WindowsSeparator); } } else @@ -215,12 +215,12 @@ private static string SeparatorWrapper(Func pathMethod, string p { var convertedToUnix = path.Replace(WindowsSeparator, LinuxSeparator); var unixResult = pathMethod(convertedToUnix); - finalResult = unixResult.Replace(LinuxSeparator, WindowsSeparator); + finalResult = unixResult?.Replace(LinuxSeparator, WindowsSeparator); } else { finalResult = pathMethod(path); - finalResult = finalResult.Replace(WindowsSeparator, LinuxSeparator); + finalResult = finalResult?.Replace(WindowsSeparator, LinuxSeparator); } } From 7fd735bd3ddeb485e4b7156cd1ddf137923fde9e Mon Sep 17 00:00:00 2001 From: Michiel Oda Date: Tue, 10 Feb 2026 14:08:12 +0100 Subject: [PATCH 2/2] Fix tests so that they aren't bound to the targetframework --- FileSystemTests/PathIOLinuxTests.cs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/FileSystemTests/PathIOLinuxTests.cs b/FileSystemTests/PathIOLinuxTests.cs index 1a25916..46cdf01 100644 --- a/FileSystemTests/PathIOLinuxTests.cs +++ b/FileSystemTests/PathIOLinuxTests.cs @@ -97,10 +97,8 @@ public void GetFullPathTest_NoSubFolder_Windows() PathIOLinux linux = new PathIOLinux(); var result = linux.GetFullPath(pathToTest); - Assert.IsTrue(result.Contains(":"), "Does not have the drive letter root"); - bool forNet472 = result.EndsWith("FileSystemTests/bin/Debug/net472/Skyline.DataMiner.CICD.FileSystem.dll"); - bool for6 = result.EndsWith("FileSystemTests/bin/Debug/net6.0/Skyline.DataMiner.CICD.FileSystem.dll"); - Assert.IsTrue(for6 || forNet472, "Does not have the full path: " + result); + result.Should().NotBeNullOrWhiteSpace(); + result.Should().ContainAll(":", "FileSystemTests/bin/Debug/net", "/Skyline.DataMiner.CICD.FileSystem.dll"); } [TestMethod] @@ -111,11 +109,8 @@ public void GetFullPathTest_WithSubFolder_Linux() PathIOLinux linux = new PathIOLinux(); var result = linux.GetFullPath(pathToTest); - Assert.IsTrue(result.Contains(":"), "Does not have the drive letter root"); - - bool forNet472 = result.EndsWith("FileSystemTests/bin/Debug/net472/SubFolderTest/TestFile.xml"); - bool for6 = result.EndsWith("FileSystemTests/bin/Debug/net6.0/SubFolderTest/TestFile.xml"); - Assert.IsTrue(for6 || forNet472, "Does not have the full path." + result); + result.Should().NotBeNullOrWhiteSpace(); + result.Should().ContainAll(":", "FileSystemTests/bin/Debug/net", "/SubFolderTest/TestFile.xml"); } [TestMethod] @@ -126,10 +121,8 @@ public void GetFullPathTest_WithSubFolder_Windows() PathIOLinux linux = new PathIOLinux(); var result = linux.GetFullPath(pathToTest); - Assert.IsTrue(result.Contains(":"), "Does not have the drive letter root"); - bool forNet472 = result.EndsWith("FileSystemTests\\bin\\Debug\\net472\\SubFolderTest\\TestFile.xml"); - bool for6 = result.EndsWith("FileSystemTests\\bin\\Debug\\net6.0\\SubFolderTest\\TestFile.xml"); - Assert.IsTrue(for6 || forNet472, "Does not have the full path." + result); + result.Should().NotBeNullOrWhiteSpace(); + result.Should().ContainAll(":", "FileSystemTests\\bin\\Debug\\net", "\\SubFolderTest\\TestFile.xml"); } [TestMethod]