From e11198616ef390b0ed73404e12a2eb130d65a55d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Oct 2025 10:20:05 +0000 Subject: [PATCH] Address code review feedback: use RuntimeInformation for platform detection - Replace Environment.OSVersion.Platform with RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - Clarify test comment about platform-specific behavior - Add using System.Runtime.InteropServices for RuntimeInformation Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com> --- src/SharpCompress/Common/ExtractionMethods.cs | 3 ++- tests/SharpCompress.Test/ExtractionTests.cs | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/SharpCompress/Common/ExtractionMethods.cs b/src/SharpCompress/Common/ExtractionMethods.cs index 0e3889bf..485fdf4d 100644 --- a/src/SharpCompress/Common/ExtractionMethods.cs +++ b/src/SharpCompress/Common/ExtractionMethods.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; @@ -12,7 +13,7 @@ internal static class ExtractionMethods /// Windows uses case-insensitive file systems, while Unix-like systems use case-sensitive file systems. /// private static StringComparison PathComparison => - Environment.OSVersion.Platform == PlatformID.Win32NT + RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; diff --git a/tests/SharpCompress.Test/ExtractionTests.cs b/tests/SharpCompress.Test/ExtractionTests.cs index baf12d30..04b5b08f 100644 --- a/tests/SharpCompress.Test/ExtractionTests.cs +++ b/tests/SharpCompress.Test/ExtractionTests.cs @@ -13,11 +13,12 @@ public class ExtractionTests : TestBase [Fact] public void Extraction_ShouldHandleCaseInsensitivePathsOnWindows() { - // This test simulates the issue where Path.GetFullPath returns paths with different casing - // than the actual directory on disk (e.g., "system32" vs "System32" on Windows). - // On Windows, file paths are case-insensitive, so the extraction should succeed. - // On Unix-like systems, file paths are case-sensitive, so this test validates the - // platform-specific behavior. + // This test validates that extraction succeeds when Path.GetFullPath returns paths + // with casing that matches the platform's file system behavior. On Windows, + // Path.GetFullPath can return different casing than the actual directory on disk + // (e.g., "system32" vs "System32"), and the extraction should succeed because + // Windows file systems are case-insensitive. On Unix-like systems, this test + // verifies that the case-sensitive comparison is used correctly. var testArchive = Path.Combine(SCRATCH2_FILES_PATH, "test-extraction.zip"); var extractPath = SCRATCH_FILES_PATH;