From bdf3294ad9adf84bdd855478e628cfc24eb7f459 Mon Sep 17 00:00:00 2001 From: ancplua Date: Thu, 14 May 2026 23:48:12 +0200 Subject: [PATCH] chore(fileops): route ShowDirectory OS dispatch through ISystemEnvironment After PR #6 added ReadAllTextAsync to ISystemEnvironment, FileOperations. ShowDirectory was still the one production-code site outside the RuntimeSystemEnvironment implementation that called OperatingSystem.* / File.* directly. Route the Windows/macOS detection through RuntimeSystemEnvironment.Instance so the abstraction is actually closed: RuntimeSystemEnvironment.cs is now the sole site touching OperatingSystem.*, Environment.Is64BitOperatingSystem, File.Exists, and File.ReadAllTextAsync. Behavior unchanged. ShowDirectory remains [ExcludeFromCodeCoverage] because the Process.Start shell-out is the untestable part, not the OS check. Co-Authored-By: Claude Opus 4.7 (1M context) --- CreatePdf.NET/Internal/FileOperations.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CreatePdf.NET/Internal/FileOperations.cs b/CreatePdf.NET/Internal/FileOperations.cs index 1a5ef4f..16f8d6e 100644 --- a/CreatePdf.NET/Internal/FileOperations.cs +++ b/CreatePdf.NET/Internal/FileOperations.cs @@ -75,12 +75,13 @@ public static void Open(string path) [ExcludeFromCodeCoverage(Justification = "Interacts with OS shell")] public static void ShowDirectory(string path) { + var environment = RuntimeSystemEnvironment.Instance; try { var (fileName, arguments) = true switch { - _ when OperatingSystem.IsWindows() => ("explorer", $"/select,\"{path}\""), - _ when OperatingSystem.IsMacOS() => ("open", $"-R \"{path}\""), + _ when environment.IsWindows => ("explorer", $"/select,\"{path}\""), + _ when environment.IsMacOS => ("open", $"-R \"{path}\""), _ => ("xdg-open", $"\"{Path.GetDirectoryName(path) ?? path}\"") };