From 2ea9d5612906ec7aba638bc7c72469751c725f0d Mon Sep 17 00:00:00 2001
From: Davide Giacometti <25966642+davidegiacometti@users.noreply.github.com>
Date: Mon, 11 Nov 2024 10:42:40 +0100
Subject: [PATCH] [Deps]Upgrade System.IO.Abstractions (#35656)
* Upgrade System.IO.Abstractions to the latest stable release
---
.pipelines/ESRPSigning_core.json | 4 +++
Directory.Packages.props | 4 +--
NOTICE.md | 4 +--
src/common/ManagedCommon/LanguageHelper.cs | 6 ++--
src/common/ManagedCommon/Logger.cs | 9 +++---
src/common/ManagedCommon/ManagedCommon.csproj | 1 -
.../Hosts/Hosts.Tests/HostsServiceTest.cs | 4 +--
.../Mocks/MockFileSystemWatcher.cs | 30 ++++++++++++-------
.../Mocks/MockFileSystemWatcherFactory.cs | 12 +++++---
.../Hosts/HostsUILib/Helpers/HostsService.cs | 8 ++---
.../WorkspacesEditor/Utils/IOUtils.cs | 2 +-
.../FancyZonesEditorCommon/Utils/IOUtils.cs | 2 +-
.../Utils/IOTestHelper.cs | 6 +++-
.../imageresizer/ui/Properties/Settings.cs | 2 +-
.../InternalQueryFolderTests.cs | 6 ++--
.../Sources/QueryFileSystemInfo.cs | 2 +-
.../Microsoft.Plugin.Program/ProgramSource.cs | 2 +-
.../launcher/Wox.Infrastructure/Helper.cs | 4 +--
.../Settings.UI.Library/LanguageModel.cs | 2 +-
.../Settings.UI.Library/UpdatingSettings.cs | 2 +-
.../Settings.UI.Library/Utilities/Helper.cs | 3 +-
.../SettingsXAML/Views/AwakePage.xaml.cs | 2 +-
22 files changed, 67 insertions(+), 50 deletions(-)
diff --git a/.pipelines/ESRPSigning_core.json b/.pipelines/ESRPSigning_core.json
index b4ee89fcf06b..5319bdc55fd9 100644
--- a/.pipelines/ESRPSigning_core.json
+++ b/.pipelines/ESRPSigning_core.json
@@ -321,6 +321,10 @@
"WinUI3Apps\\ReverseMarkdown.dll",
"WinUI3Apps\\SharpCompress.dll",
"WinUI3Apps\\ZstdSharp.dll",
+ "TestableIO.System.IO.Abstractions.dll",
+ "WinUI3Apps\\TestableIO.System.IO.Abstractions.dll",
+ "TestableIO.System.IO.Abstractions.Wrappers.dll",
+ "WinUI3Apps\\TestableIO.System.IO.Abstractions.Wrappers.dll",
"ColorCode.Core.dll",
"ColorCode.UWP.dll",
"UnitsNet.dll",
diff --git a/Directory.Packages.props b/Directory.Packages.props
index a103ca59a84d..db4de0da4de0 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -73,8 +73,8 @@
-
-
+
+
diff --git a/NOTICE.md b/NOTICE.md
index 38c961a11619..ea5e811bb0f4 100644
--- a/NOTICE.md
+++ b/NOTICE.md
@@ -1354,8 +1354,8 @@ EXHIBIT A -Mozilla Public License.
- System.Data.SqlClient 4.8.6
- System.Diagnostics.EventLog 8.0.1
- System.Drawing.Common 8.0.7
-- System.IO.Abstractions 17.2.3
-- System.IO.Abstractions.TestingHelpers 17.2.3
+- System.IO.Abstractions 21.0.29
+- System.IO.Abstractions.TestingHelpers 21.0.29
- System.Management 8.0.0
- System.Reactive 6.0.1
- System.Runtime.Caching 8.0.1
diff --git a/src/common/ManagedCommon/LanguageHelper.cs b/src/common/ManagedCommon/LanguageHelper.cs
index 90791a03bc5f..85cdcd1c335e 100644
--- a/src/common/ManagedCommon/LanguageHelper.cs
+++ b/src/common/ManagedCommon/LanguageHelper.cs
@@ -4,7 +4,6 @@
using System;
using System.IO;
-using System.IO.Abstractions;
using System.Text.Json;
using System.Text.Json.Serialization;
@@ -23,15 +22,14 @@ internal sealed class OutGoingLanguageSettings
public static string LoadLanguage()
{
- FileSystem fileSystem = new FileSystem();
var localAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
var file = localAppDataDir + SettingsFilePath + SettingsFile;
- if (fileSystem.File.Exists(file))
+ if (File.Exists(file))
{
try
{
- Stream inputStream = fileSystem.File.Open(file, FileMode.Open);
+ var inputStream = File.Open(file, FileMode.Open);
StreamReader reader = new StreamReader(inputStream);
string data = reader.ReadToEnd();
inputStream.Close();
diff --git a/src/common/ManagedCommon/Logger.cs b/src/common/ManagedCommon/Logger.cs
index bbc2637fd956..367480d293a2 100644
--- a/src/common/ManagedCommon/Logger.cs
+++ b/src/common/ManagedCommon/Logger.cs
@@ -5,7 +5,7 @@
using System;
using System.Diagnostics;
using System.Globalization;
-using System.IO.Abstractions;
+using System.IO;
using System.Reflection;
using PowerToys.Interop;
@@ -14,7 +14,6 @@ namespace ManagedCommon
{
public static class Logger
{
- private static readonly IFileSystem _fileSystem = new FileSystem();
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
private static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location).ProductVersion;
@@ -41,12 +40,12 @@ public static void InitializeLogger(string applicationLogPath, bool isLocalLow =
applicationLogPath = Constants.AppDataPath() + applicationLogPath + "\\" + Version;
}
- if (!_fileSystem.Directory.Exists(applicationLogPath))
+ if (!Directory.Exists(applicationLogPath))
{
- _fileSystem.Directory.CreateDirectory(applicationLogPath);
+ Directory.CreateDirectory(applicationLogPath);
}
- var logFilePath = _fileSystem.Path.Combine(applicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt");
+ var logFilePath = Path.Combine(applicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt");
Trace.Listeners.Add(new TextWriterTraceListener(logFilePath));
diff --git a/src/common/ManagedCommon/ManagedCommon.csproj b/src/common/ManagedCommon/ManagedCommon.csproj
index 164df854eb0b..f3b149616c4c 100644
--- a/src/common/ManagedCommon/ManagedCommon.csproj
+++ b/src/common/ManagedCommon/ManagedCommon.csproj
@@ -15,7 +15,6 @@
-
diff --git a/src/modules/Hosts/Hosts.Tests/HostsServiceTest.cs b/src/modules/Hosts/Hosts.Tests/HostsServiceTest.cs
index b57fbf42ed0f..8eaa37a34811 100644
--- a/src/modules/Hosts/Hosts.Tests/HostsServiceTest.cs
+++ b/src/modules/Hosts/Hosts.Tests/HostsServiceTest.cs
@@ -276,7 +276,7 @@ public void Remove_ReadOnly_Attribute()
service.RemoveReadOnlyAttribute();
- var readOnly = fileSystem.FileInfo.FromFileName(service.HostsFilePath).Attributes.HasFlag(FileAttributes.ReadOnly);
+ var readOnly = fileSystem.FileInfo.New(service.HostsFilePath).Attributes.HasFlag(FileAttributes.ReadOnly);
Assert.IsFalse(readOnly);
}
@@ -295,7 +295,7 @@ public async Task Save_Hidden_Hosts()
await service.WriteAsync("# Empty hosts file", Enumerable.Empty());
- var hidden = fileSystem.FileInfo.FromFileName(service.HostsFilePath).Attributes.HasFlag(FileAttributes.Hidden);
+ var hidden = fileSystem.FileInfo.New(service.HostsFilePath).Attributes.HasFlag(FileAttributes.Hidden);
Assert.IsTrue(hidden);
}
}
diff --git a/src/modules/Hosts/Hosts.Tests/Mocks/MockFileSystemWatcher.cs b/src/modules/Hosts/Hosts.Tests/Mocks/MockFileSystemWatcher.cs
index 0cbabd217b63..5061a6d815c6 100644
--- a/src/modules/Hosts/Hosts.Tests/Mocks/MockFileSystemWatcher.cs
+++ b/src/modules/Hosts/Hosts.Tests/Mocks/MockFileSystemWatcher.cs
@@ -2,6 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
@@ -9,7 +10,7 @@
namespace Hosts.Tests.Mocks
{
- public class MockFileSystemWatcher : FileSystemWatcherBase
+ public partial class MockFileSystemWatcher : FileSystemWatcherBase
{
public override bool IncludeSubdirectories { get; set; }
@@ -27,26 +28,35 @@ public class MockFileSystemWatcher : FileSystemWatcherBase
public override ISynchronizeInvoke SynchronizingObject { get; set; }
- public override Collection Filters => throw new System.NotImplementedException();
+ public override Collection Filters => throw new NotImplementedException();
- public override WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType) => default;
+ public override IFileSystem FileSystem => throw new NotImplementedException();
- public override WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout) => default;
+ public override IContainer Container => throw new NotImplementedException();
- public MockFileSystemWatcher(string path) => Path = path;
+ public override void BeginInit() => throw new NotImplementedException();
- public MockFileSystemWatcher(string path, string filter)
+ public override void EndInit() => throw new NotImplementedException();
+
+ public override IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, TimeSpan timeout) => throw new NotImplementedException();
+
+ public override IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType) => throw new NotImplementedException();
+
+ public override IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout) => throw new NotImplementedException();
+
+ public MockFileSystemWatcher()
{
- Path = path;
- Filter = filter;
}
- public override void BeginInit()
+ public MockFileSystemWatcher(string path)
{
+ Path = path;
}
- public override void EndInit()
+ public MockFileSystemWatcher(string path, string filter)
{
+ Path = path;
+ Filter = filter;
}
}
}
diff --git a/src/modules/Hosts/Hosts.Tests/Mocks/MockFileSystemWatcherFactory.cs b/src/modules/Hosts/Hosts.Tests/Mocks/MockFileSystemWatcherFactory.cs
index 3e0b4de140b4..bef93daf2b49 100644
--- a/src/modules/Hosts/Hosts.Tests/Mocks/MockFileSystemWatcherFactory.cs
+++ b/src/modules/Hosts/Hosts.Tests/Mocks/MockFileSystemWatcherFactory.cs
@@ -2,18 +2,22 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System;
+using System.IO;
using System.IO.Abstractions;
namespace Hosts.Tests.Mocks
{
public class MockFileSystemWatcherFactory : IFileSystemWatcherFactory
{
- public IFileSystemWatcher CreateNew() => new MockFileSystemWatcher(null);
+ public IFileSystem FileSystem => throw new NotImplementedException();
- public IFileSystemWatcher CreateNew(string path) => new MockFileSystemWatcher(path);
+ public IFileSystemWatcher New() => new MockFileSystemWatcher();
- public IFileSystemWatcher CreateNew(string path, string filter) => new MockFileSystemWatcher(path, filter);
+ public IFileSystemWatcher New(string path) => new MockFileSystemWatcher(path);
- public IFileSystemWatcher FromPath(string path) => new MockFileSystemWatcher(path);
+ public IFileSystemWatcher New(string path, string filter) => new MockFileSystemWatcher(path, filter);
+
+ public IFileSystemWatcher Wrap(FileSystemWatcher fileSystemWatcher) => throw new NotImplementedException();
}
}
diff --git a/src/modules/Hosts/HostsUILib/Helpers/HostsService.cs b/src/modules/Hosts/HostsUILib/Helpers/HostsService.cs
index a6c1981a82bc..3270681c5e90 100644
--- a/src/modules/Hosts/HostsUILib/Helpers/HostsService.cs
+++ b/src/modules/Hosts/HostsUILib/Helpers/HostsService.cs
@@ -52,7 +52,7 @@ public HostsService(
_hostsFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), @"System32\drivers\etc\hosts");
- _fileSystemWatcher = _fileSystem.FileSystemWatcher.CreateNew();
+ _fileSystemWatcher = _fileSystem.FileSystemWatcher.New();
_fileSystemWatcher.Path = _fileSystem.Path.GetDirectoryName(HostsFilePath);
_fileSystemWatcher.Filter = _fileSystem.Path.GetFileName(HostsFilePath);
_fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite;
@@ -130,7 +130,7 @@ public async Task WriteAsync(string additionalLines, IEnumerable entries)
throw new NotRunningElevatedException();
}
- if (_fileSystem.FileInfo.FromFileName(HostsFilePath).IsReadOnly)
+ if (_fileSystem.FileInfo.New(HostsFilePath).IsReadOnly)
{
throw new ReadOnlyHostsException();
}
@@ -200,7 +200,7 @@ public async Task WriteAsync(string additionalLines, IEnumerable entries)
}
// FileMode.OpenOrCreate is necessary to prevent UnauthorizedAccessException when the hosts file is hidden
- using var stream = _fileSystem.FileStream.Create(HostsFilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read, _defaultBufferSize, FileOptions.Asynchronous);
+ using var stream = _fileSystem.FileStream.New(HostsFilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read, _defaultBufferSize, FileOptions.Asynchronous);
using var writer = new StreamWriter(stream, Encoding);
foreach (var line in lines)
{
@@ -305,7 +305,7 @@ public void OpenHostsFile()
public void RemoveReadOnlyAttribute()
{
- var fileInfo = _fileSystem.FileInfo.FromFileName(HostsFilePath);
+ var fileInfo = _fileSystem.FileInfo.New(HostsFilePath);
if (fileInfo.IsReadOnly)
{
fileInfo.IsReadOnly = false;
diff --git a/src/modules/Workspaces/WorkspacesEditor/Utils/IOUtils.cs b/src/modules/Workspaces/WorkspacesEditor/Utils/IOUtils.cs
index 1ec08a79ff45..075067cb142b 100644
--- a/src/modules/Workspaces/WorkspacesEditor/Utils/IOUtils.cs
+++ b/src/modules/Workspaces/WorkspacesEditor/Utils/IOUtils.cs
@@ -31,7 +31,7 @@ public string ReadFile(string fileName)
{
try
{
- using (Stream inputStream = _fileSystem.File.Open(fileName, FileMode.Open))
+ using (FileSystemStream inputStream = _fileSystem.File.Open(fileName, FileMode.Open))
using (StreamReader reader = new StreamReader(inputStream))
{
string data = reader.ReadToEnd();
diff --git a/src/modules/fancyzones/FancyZonesEditorCommon/Utils/IOUtils.cs b/src/modules/fancyzones/FancyZonesEditorCommon/Utils/IOUtils.cs
index f48a34169557..f11e0a2d0e64 100644
--- a/src/modules/fancyzones/FancyZonesEditorCommon/Utils/IOUtils.cs
+++ b/src/modules/fancyzones/FancyZonesEditorCommon/Utils/IOUtils.cs
@@ -31,7 +31,7 @@ public string ReadFile(string fileName)
{
try
{
- using (Stream inputStream = _fileSystem.File.Open(fileName, FileMode.Open))
+ using (FileSystemStream inputStream = _fileSystem.File.Open(fileName, FileMode.Open))
using (StreamReader reader = new StreamReader(inputStream))
{
string data = reader.ReadToEnd();
diff --git a/src/modules/fancyzones/UITests-FancyZonesEditor/Utils/IOTestHelper.cs b/src/modules/fancyzones/UITests-FancyZonesEditor/Utils/IOTestHelper.cs
index d472154ac578..7c52ca0c95ad 100644
--- a/src/modules/fancyzones/UITests-FancyZonesEditor/Utils/IOTestHelper.cs
+++ b/src/modules/fancyzones/UITests-FancyZonesEditor/Utils/IOTestHelper.cs
@@ -27,7 +27,11 @@ public IOTestHelper(string file)
}
else
{
- _fileSystem.Directory.CreateDirectory(Path.GetDirectoryName(file));
+ var path = Path.GetDirectoryName(file);
+ if (path != null)
+ {
+ _fileSystem.Directory.CreateDirectory(path);
+ }
}
}
diff --git a/src/modules/imageresizer/ui/Properties/Settings.cs b/src/modules/imageresizer/ui/Properties/Settings.cs
index 6beceeb0820e..3150f9768fb7 100644
--- a/src/modules/imageresizer/ui/Properties/Settings.cs
+++ b/src/modules/imageresizer/ui/Properties/Settings.cs
@@ -421,7 +421,7 @@ public void Save()
string jsonData = JsonSerializer.Serialize(new SettingsWrapper() { Properties = this }, _jsonSerializerOptions);
// Create directory if it doesn't exist
- IFileInfo file = _fileSystem.FileInfo.FromFileName(SettingsPath);
+ IFileInfo file = _fileSystem.FileInfo.New(SettingsPath);
file.Directory.Create();
// write string to file
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/InternalQueryFolderTests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/InternalQueryFolderTests.cs
index 4bece3c81c71..db4fc8f2a1b0 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/InternalQueryFolderTests.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/InternalQueryFolderTests.cs
@@ -51,7 +51,7 @@ public void Query_ThrowsException_WhenCalledNull()
[DataRow(@"c:", 2, 1, false, DisplayName = "Root without \\")]
[DataRow(@"c:\", 2, 1, false, DisplayName = "Normal root")]
[DataRow(@"c:\Test", 2, 2, false, DisplayName = "Select yourself")]
- [DataRow(@"c:\not-exist", 2, 1, false, DisplayName = "Folder not exist, return root")]
+ [DataRow(@"c:\not-exist", 2, 0, false, DisplayName = "Folder not exist, return root")]
[DataRow(@"c:\not-exist\not-exist2", 0, 0, false, DisplayName = "Folder not exist, return root")]
[DataRow(@"c:\bla.t", 2, 1, false, DisplayName = "Partial match file")]
[DataRow(@"c:/bla.t", 2, 1, false, DisplayName = "Partial match file with /")]
@@ -88,8 +88,8 @@ public void Query_WhenCalled(string search, int folders, int files, bool truncat
[DataTestMethod]
[DataRow(@"c:\>", 3, 3, true, DisplayName = "Max Folder test recursive")]
- [DataRow(@"c:\Test>", 3, 3, true, DisplayName = "2 Folders recursive")]
- [DataRow(@"c:\not-exist>", 3, 3, true, DisplayName = "Folder not exist, return root recursive")]
+ [DataRow(@"c:\Test>", 3, 0, true, DisplayName = "2 Folders recursive")]
+ [DataRow(@"c:\not-exist>", 3, 0, true, DisplayName = "Folder not exist, return root recursive")]
[DataRow(@"c:\not-exist\not-exist2>", 0, 0, false, DisplayName = "Folder not exist, return root recursive")]
public void Query_Recursive_WhenCalled(string search, int folders, int files, bool truncated)
{
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Sources/QueryFileSystemInfo.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Sources/QueryFileSystemInfo.cs
index b67a329c84db..ec9a1e28f318 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Sources/QueryFileSystemInfo.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Sources/QueryFileSystemInfo.cs
@@ -25,7 +25,7 @@ public QueryFileSystemInfo(IDirectoryInfoFactory directoryInfoFactory, MatchType
public IEnumerable MatchFileSystemInfo(string search, string incompleteName, bool isRecursive)
{
// search folder and add results
- var directoryInfo = _directoryInfoFactory.FromDirectoryName(search);
+ var directoryInfo = _directoryInfoFactory.New(search);
var fileSystemInfos = directoryInfo.EnumerateFileSystemInfos(incompleteName, new EnumerationOptions
{
MatchType = _matchType,
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/ProgramSource.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/ProgramSource.cs
index 8406bd8bc842..de87652ed88a 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/ProgramSource.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/ProgramSource.cs
@@ -22,7 +22,7 @@ public class ProgramSource
public string Location { get; set; }
- public string Name { get => name ?? FileSystem.DirectoryInfo.FromDirectoryName(Location).Name; set => name = value; }
+ public string Name { get => name ?? FileSystem.DirectoryInfo.New(Location).Name; set => name = value; }
public bool Enabled { get; set; } = true;
diff --git a/src/modules/launcher/Wox.Infrastructure/Helper.cs b/src/modules/launcher/Wox.Infrastructure/Helper.cs
index 40026d35b9ec..96313e60b565 100644
--- a/src/modules/launcher/Wox.Infrastructure/Helper.cs
+++ b/src/modules/launcher/Wox.Infrastructure/Helper.cs
@@ -71,8 +71,8 @@ public static void ValidateDataDirectory(string bundledDataDirectory, string dat
}
else
{
- var time1 = FileInfo.FromFileName(bundledDataPath).LastWriteTimeUtc;
- var time2 = FileInfo.FromFileName(dataPath).LastWriteTimeUtc;
+ var time1 = FileInfo.New(bundledDataPath).LastWriteTimeUtc;
+ var time2 = FileInfo.New(dataPath).LastWriteTimeUtc;
if (time1 != time2)
{
File.Copy(bundledDataPath, dataPath, true);
diff --git a/src/settings-ui/Settings.UI.Library/LanguageModel.cs b/src/settings-ui/Settings.UI.Library/LanguageModel.cs
index 1e9ef82ec658..63652aba73e5 100644
--- a/src/settings-ui/Settings.UI.Library/LanguageModel.cs
+++ b/src/settings-ui/Settings.UI.Library/LanguageModel.cs
@@ -30,7 +30,7 @@ public static string LoadSetting()
{
try
{
- Stream inputStream = fileSystem.File.Open(file, FileMode.Open);
+ FileSystemStream inputStream = fileSystem.File.Open(file, FileMode.Open);
StreamReader reader = new StreamReader(inputStream);
string data = reader.ReadToEnd();
inputStream.Close();
diff --git a/src/settings-ui/Settings.UI.Library/UpdatingSettings.cs b/src/settings-ui/Settings.UI.Library/UpdatingSettings.cs
index 16e9e50ab760..b5244bbc0085 100644
--- a/src/settings-ui/Settings.UI.Library/UpdatingSettings.cs
+++ b/src/settings-ui/Settings.UI.Library/UpdatingSettings.cs
@@ -102,7 +102,7 @@ public static UpdatingSettings LoadSettings()
{
try
{
- Stream inputStream = fileSystem.File.Open(file, FileMode.Open);
+ FileSystemStream inputStream = fileSystem.File.Open(file, FileMode.Open);
StreamReader reader = new StreamReader(inputStream);
string data = reader.ReadToEnd();
inputStream.Close();
diff --git a/src/settings-ui/Settings.UI.Library/Utilities/Helper.cs b/src/settings-ui/Settings.UI.Library/Utilities/Helper.cs
index fc1f8d6f7cf3..58d1f5f46927 100644
--- a/src/settings-ui/Settings.UI.Library/Utilities/Helper.cs
+++ b/src/settings-ui/Settings.UI.Library/Utilities/Helper.cs
@@ -7,7 +7,6 @@
using System.IO;
using System.IO.Abstractions;
using System.Linq;
-using System.Net.NetworkInformation;
using System.Security.Principal;
using Microsoft.PowerToys.Settings.UI.Library.CustomAction;
@@ -63,7 +62,7 @@ public static IFileSystemWatcher GetFileWatcher(string moduleName, string fileNa
FileSystem.Directory.CreateDirectory(path);
}
- var watcher = FileSystem.FileSystemWatcher.CreateNew();
+ var watcher = FileSystem.FileSystemWatcher.New();
watcher.Path = path;
watcher.Filter = fileName;
watcher.NotifyFilter = NotifyFilters.LastWrite;
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/AwakePage.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/Views/AwakePage.xaml.cs
index b30ff668443d..49861c3c0b49 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/AwakePage.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/AwakePage.xaml.cs
@@ -54,7 +54,7 @@ public AwakePage()
var settingsPath = _settingsUtils.GetSettingsFilePath(_appName);
- _fileSystemWatcher = _fileSystem.FileSystemWatcher.CreateNew();
+ _fileSystemWatcher = _fileSystem.FileSystemWatcher.New();
_fileSystemWatcher.Path = _fileSystem.Path.GetDirectoryName(settingsPath);
_fileSystemWatcher.Filter = _fileSystem.Path.GetFileName(settingsPath);
_fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.CreationTime;