From 4043d19bdad9209d40706151b92904827dcfcc9c Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sun, 8 Mar 2026 14:32:21 +1100 Subject: [PATCH] Use MoveFile and remove CopyFile/DeleteFile Unify file-moving logic by removing the NETCOREAPP conditional and calling IFileSystem.MoveFile unconditionally in RetryOrchestrator. Remove CopyFile and DeleteFile members from IFileSystem and their implementations in SystemFileSystem, simplifying the file system abstraction. --- .../Microsoft.Testing.Extensions.Retry/RetryOrchestrator.cs | 5 ----- .../Microsoft.Testing.Platform/Helpers/System/IFileSystem.cs | 4 ---- .../Helpers/System/SystemFileSystem.cs | 4 ---- 3 files changed, 13 deletions(-) diff --git a/src/Platform/Microsoft.Testing.Extensions.Retry/RetryOrchestrator.cs b/src/Platform/Microsoft.Testing.Extensions.Retry/RetryOrchestrator.cs index 5aeb86304a..e5e6a512ad 100644 --- a/src/Platform/Microsoft.Testing.Extensions.Retry/RetryOrchestrator.cs +++ b/src/Platform/Microsoft.Testing.Extensions.Retry/RetryOrchestrator.cs @@ -323,12 +323,7 @@ public async Task OrchestrateTestHostExecutionAsync(CancellationToken cance fileSystem.CreateDirectory(Path.GetDirectoryName(finalFileLocation)!); await outputDevice.DisplayAsync(this, new TextOutputDeviceData(string.Format(CultureInfo.InvariantCulture, ExtensionResources.MovingFileToLocation, file, finalFileLocation)), cancellationToken).ConfigureAwait(false); -#if NETCOREAPP fileSystem.MoveFile(file, finalFileLocation, overwrite: true); -#else - fileSystem.CopyFile(file, finalFileLocation, overwrite: true); - fileSystem.DeleteFile(file); -#endif } } diff --git a/src/Platform/Microsoft.Testing.Platform/Helpers/System/IFileSystem.cs b/src/Platform/Microsoft.Testing.Platform/Helpers/System/IFileSystem.cs index ca8e8fd431..903f5f553e 100644 --- a/src/Platform/Microsoft.Testing.Platform/Helpers/System/IFileSystem.cs +++ b/src/Platform/Microsoft.Testing.Platform/Helpers/System/IFileSystem.cs @@ -21,9 +21,5 @@ internal interface IFileSystem Task ReadAllTextAsync(string path); - void CopyFile(string sourceFileName, string destFileName, bool overwrite = false); - - void DeleteFile(string path); - string[] GetFiles(string path, string searchPattern, SearchOption searchOption); } diff --git a/src/Platform/Microsoft.Testing.Platform/Helpers/System/SystemFileSystem.cs b/src/Platform/Microsoft.Testing.Platform/Helpers/System/SystemFileSystem.cs index d88cbf742a..ad3d5efe6a 100644 --- a/src/Platform/Microsoft.Testing.Platform/Helpers/System/SystemFileSystem.cs +++ b/src/Platform/Microsoft.Testing.Platform/Helpers/System/SystemFileSystem.cs @@ -19,10 +19,6 @@ internal sealed class SystemFileSystem : IFileSystem public Task ReadAllTextAsync(string path) => File.ReadAllTextAsync(path); - public void CopyFile(string sourceFileName, string destFileName, bool overwrite = false) => File.Copy(sourceFileName, destFileName, overwrite); - - public void DeleteFile(string path) => File.Delete(path); - public bool ExistDirectory(string? path) => Directory.Exists(path); public string[] GetFiles(string path, string searchPattern, SearchOption searchOption) => Directory.GetFiles(path, searchPattern, searchOption);