Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4a23ba2

Browse files
authoredNov 12, 2024
Merge upstream main (#149)
* [Settings]Fix release cycle links in OOBE What's New page (#35801) * Fix release cycle link in OOBE Previously it would point to the 5ft last release instead. * Adressed feedback * [Deps]Upgrade System.IO.Abstractions (#35656) * Upgrade System.IO.Abstractions to the latest stable release
1 parent 8344fe7 commit 4a23ba2

File tree

23 files changed

+72
-51
lines changed

23 files changed

+72
-51
lines changed
 

‎.pipelines/ESRPSigning_core.json

+4
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@
321321
"WinUI3Apps\\ReverseMarkdown.dll",
322322
"WinUI3Apps\\SharpCompress.dll",
323323
"WinUI3Apps\\ZstdSharp.dll",
324+
"TestableIO.System.IO.Abstractions.dll",
325+
"WinUI3Apps\\TestableIO.System.IO.Abstractions.dll",
326+
"TestableIO.System.IO.Abstractions.Wrappers.dll",
327+
"WinUI3Apps\\TestableIO.System.IO.Abstractions.Wrappers.dll",
324328
"ColorCode.Core.dll",
325329
"ColorCode.UWP.dll",
326330
"UnitsNet.dll",

‎Directory.Packages.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@
7777
<!-- Package System.Diagnostics.EventLog added as a hack for being able to exclude the runtime assets so they don't conflict with 8.0.1. This is a dependency of System.Data.OleDb but the 8.0.1 version wasn't published to nuget. -->
7878
<PackageVersion Include="System.Diagnostics.EventLog" Version="8.0.1" />
7979
<PackageVersion Include="System.Drawing.Common" Version="8.0.7" />
80-
<PackageVersion Include="System.IO.Abstractions" Version="17.2.3" />
81-
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="17.2.3" />
80+
<PackageVersion Include="System.IO.Abstractions" Version="21.0.29" />
81+
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="21.0.29" />
8282
<PackageVersion Include="System.Management" Version="8.0.0" />
8383
<PackageVersion Include="System.Reactive" Version="6.0.1" />
8484
<PackageVersion Include="System.Runtime.Caching" Version="8.0.1" />

‎NOTICE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1354,8 +1354,8 @@ EXHIBIT A -Mozilla Public License.
13541354
- System.Data.SqlClient 4.8.6
13551355
- System.Diagnostics.EventLog 8.0.1
13561356
- System.Drawing.Common 8.0.7
1357-
- System.IO.Abstractions 17.2.3
1358-
- System.IO.Abstractions.TestingHelpers 17.2.3
1357+
- System.IO.Abstractions 21.0.29
1358+
- System.IO.Abstractions.TestingHelpers 21.0.29
13591359
- System.Management 8.0.0
13601360
- System.Reactive 6.0.1
13611361
- System.Runtime.Caching 8.0.1

‎src/common/ManagedCommon/LanguageHelper.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using System;
66
using System.IO;
7-
using System.IO.Abstractions;
87
using System.Text.Json;
98
using System.Text.Json.Serialization;
109

@@ -23,15 +22,14 @@ internal sealed class OutGoingLanguageSettings
2322

2423
public static string LoadLanguage()
2524
{
26-
FileSystem fileSystem = new FileSystem();
2725
var localAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
2826
var file = localAppDataDir + SettingsFilePath + SettingsFile;
2927

30-
if (fileSystem.File.Exists(file))
28+
if (File.Exists(file))
3129
{
3230
try
3331
{
34-
Stream inputStream = fileSystem.File.Open(file, FileMode.Open);
32+
var inputStream = File.Open(file, FileMode.Open);
3533
StreamReader reader = new StreamReader(inputStream);
3634
string data = reader.ReadToEnd();
3735
inputStream.Close();

‎src/common/ManagedCommon/Logger.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System;
66
using System.Diagnostics;
77
using System.Globalization;
8-
using System.IO.Abstractions;
8+
using System.IO;
99
using System.Reflection;
1010

1111
using PowerToys.Interop;
@@ -14,7 +14,6 @@ namespace ManagedCommon
1414
{
1515
public static class Logger
1616
{
17-
private static readonly IFileSystem _fileSystem = new FileSystem();
1817
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
1918
private static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location).ProductVersion;
2019

@@ -41,12 +40,12 @@ public static void InitializeLogger(string applicationLogPath, bool isLocalLow =
4140
applicationLogPath = Constants.AppDataPath() + applicationLogPath + "\\" + Version;
4241
}
4342

44-
if (!_fileSystem.Directory.Exists(applicationLogPath))
43+
if (!Directory.Exists(applicationLogPath))
4544
{
46-
_fileSystem.Directory.CreateDirectory(applicationLogPath);
45+
Directory.CreateDirectory(applicationLogPath);
4746
}
4847

49-
var logFilePath = _fileSystem.Path.Combine(applicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt");
48+
var logFilePath = Path.Combine(applicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt");
5049

5150
Trace.Listeners.Add(new TextWriterTraceListener(logFilePath));
5251

‎src/common/ManagedCommon/ManagedCommon.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="System.IO.Abstractions" />
1918
<PackageReference Include="System.Management" />
2019
</ItemGroup>
2120

‎src/modules/Hosts/Hosts.Tests/HostsServiceTest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public void Remove_ReadOnly_Attribute()
276276

277277
service.RemoveReadOnlyAttribute();
278278

279-
var readOnly = fileSystem.FileInfo.FromFileName(service.HostsFilePath).Attributes.HasFlag(FileAttributes.ReadOnly);
279+
var readOnly = fileSystem.FileInfo.New(service.HostsFilePath).Attributes.HasFlag(FileAttributes.ReadOnly);
280280
Assert.IsFalse(readOnly);
281281
}
282282

@@ -295,7 +295,7 @@ public async Task Save_Hidden_Hosts()
295295

296296
await service.WriteAsync("# Empty hosts file", Enumerable.Empty<Entry>());
297297

298-
var hidden = fileSystem.FileInfo.FromFileName(service.HostsFilePath).Attributes.HasFlag(FileAttributes.Hidden);
298+
var hidden = fileSystem.FileInfo.New(service.HostsFilePath).Attributes.HasFlag(FileAttributes.Hidden);
299299
Assert.IsTrue(hidden);
300300
}
301301
}

‎src/modules/Hosts/Hosts.Tests/Mocks/MockFileSystemWatcher.cs

+20-10
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
// The Microsoft Corporation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
56
using System.Collections.ObjectModel;
67
using System.ComponentModel;
78
using System.IO;
89
using System.IO.Abstractions;
910

1011
namespace Hosts.Tests.Mocks
1112
{
12-
public class MockFileSystemWatcher : FileSystemWatcherBase
13+
public partial class MockFileSystemWatcher : FileSystemWatcherBase
1314
{
1415
public override bool IncludeSubdirectories { get; set; }
1516

@@ -27,26 +28,35 @@ public class MockFileSystemWatcher : FileSystemWatcherBase
2728

2829
public override ISynchronizeInvoke SynchronizingObject { get; set; }
2930

30-
public override Collection<string> Filters => throw new System.NotImplementedException();
31+
public override Collection<string> Filters => throw new NotImplementedException();
3132

32-
public override WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType) => default;
33+
public override IFileSystem FileSystem => throw new NotImplementedException();
3334

34-
public override WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout) => default;
35+
public override IContainer Container => throw new NotImplementedException();
3536

36-
public MockFileSystemWatcher(string path) => Path = path;
37+
public override void BeginInit() => throw new NotImplementedException();
3738

38-
public MockFileSystemWatcher(string path, string filter)
39+
public override void EndInit() => throw new NotImplementedException();
40+
41+
public override IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, TimeSpan timeout) => throw new NotImplementedException();
42+
43+
public override IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType) => throw new NotImplementedException();
44+
45+
public override IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout) => throw new NotImplementedException();
46+
47+
public MockFileSystemWatcher()
3948
{
40-
Path = path;
41-
Filter = filter;
4249
}
4350

44-
public override void BeginInit()
51+
public MockFileSystemWatcher(string path)
4552
{
53+
Path = path;
4654
}
4755

48-
public override void EndInit()
56+
public MockFileSystemWatcher(string path, string filter)
4957
{
58+
Path = path;
59+
Filter = filter;
5060
}
5161
}
5262
}

‎src/modules/Hosts/Hosts.Tests/Mocks/MockFileSystemWatcherFactory.cs

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22
// The Microsoft Corporation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
6+
using System.IO;
57
using System.IO.Abstractions;
68

79
namespace Hosts.Tests.Mocks
810
{
911
public class MockFileSystemWatcherFactory : IFileSystemWatcherFactory
1012
{
11-
public IFileSystemWatcher CreateNew() => new MockFileSystemWatcher(null);
13+
public IFileSystem FileSystem => throw new NotImplementedException();
1214

13-
public IFileSystemWatcher CreateNew(string path) => new MockFileSystemWatcher(path);
15+
public IFileSystemWatcher New() => new MockFileSystemWatcher();
1416

15-
public IFileSystemWatcher CreateNew(string path, string filter) => new MockFileSystemWatcher(path, filter);
17+
public IFileSystemWatcher New(string path) => new MockFileSystemWatcher(path);
1618

17-
public IFileSystemWatcher FromPath(string path) => new MockFileSystemWatcher(path);
19+
public IFileSystemWatcher New(string path, string filter) => new MockFileSystemWatcher(path, filter);
20+
21+
public IFileSystemWatcher Wrap(FileSystemWatcher fileSystemWatcher) => throw new NotImplementedException();
1822
}
1923
}

‎src/modules/Hosts/HostsUILib/Helpers/HostsService.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public HostsService(
5252

5353
_hostsFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), @"System32\drivers\etc\hosts");
5454

55-
_fileSystemWatcher = _fileSystem.FileSystemWatcher.CreateNew();
55+
_fileSystemWatcher = _fileSystem.FileSystemWatcher.New();
5656
_fileSystemWatcher.Path = _fileSystem.Path.GetDirectoryName(HostsFilePath);
5757
_fileSystemWatcher.Filter = _fileSystem.Path.GetFileName(HostsFilePath);
5858
_fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite;
@@ -130,7 +130,7 @@ public async Task WriteAsync(string additionalLines, IEnumerable<Entry> entries)
130130
throw new NotRunningElevatedException();
131131
}
132132

133-
if (_fileSystem.FileInfo.FromFileName(HostsFilePath).IsReadOnly)
133+
if (_fileSystem.FileInfo.New(HostsFilePath).IsReadOnly)
134134
{
135135
throw new ReadOnlyHostsException();
136136
}
@@ -200,7 +200,7 @@ public async Task WriteAsync(string additionalLines, IEnumerable<Entry> entries)
200200
}
201201

202202
// FileMode.OpenOrCreate is necessary to prevent UnauthorizedAccessException when the hosts file is hidden
203-
using var stream = _fileSystem.FileStream.Create(HostsFilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read, _defaultBufferSize, FileOptions.Asynchronous);
203+
using var stream = _fileSystem.FileStream.New(HostsFilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read, _defaultBufferSize, FileOptions.Asynchronous);
204204
using var writer = new StreamWriter(stream, Encoding);
205205
foreach (var line in lines)
206206
{
@@ -305,7 +305,7 @@ public void OpenHostsFile()
305305

306306
public void RemoveReadOnlyAttribute()
307307
{
308-
var fileInfo = _fileSystem.FileInfo.FromFileName(HostsFilePath);
308+
var fileInfo = _fileSystem.FileInfo.New(HostsFilePath);
309309
if (fileInfo.IsReadOnly)
310310
{
311311
fileInfo.IsReadOnly = false;

‎src/modules/Workspaces/WorkspacesEditor/Utils/IOUtils.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public string ReadFile(string fileName)
3131
{
3232
try
3333
{
34-
using (Stream inputStream = _fileSystem.File.Open(fileName, FileMode.Open))
34+
using (FileSystemStream inputStream = _fileSystem.File.Open(fileName, FileMode.Open))
3535
using (StreamReader reader = new StreamReader(inputStream))
3636
{
3737
string data = reader.ReadToEnd();

‎src/modules/fancyzones/FancyZonesEditorCommon/Utils/IOUtils.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public string ReadFile(string fileName)
3131
{
3232
try
3333
{
34-
using (Stream inputStream = _fileSystem.File.Open(fileName, FileMode.Open))
34+
using (FileSystemStream inputStream = _fileSystem.File.Open(fileName, FileMode.Open))
3535
using (StreamReader reader = new StreamReader(inputStream))
3636
{
3737
string data = reader.ReadToEnd();

‎src/modules/fancyzones/UITests-FancyZonesEditor/Utils/IOTestHelper.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ public IOTestHelper(string file)
2727
}
2828
else
2929
{
30-
_fileSystem.Directory.CreateDirectory(Path.GetDirectoryName(file));
30+
var path = Path.GetDirectoryName(file);
31+
if (path != null)
32+
{
33+
_fileSystem.Directory.CreateDirectory(path);
34+
}
3135
}
3236
}
3337

‎src/modules/imageresizer/ui/Properties/Settings.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ public void Save()
421421
string jsonData = JsonSerializer.Serialize(new SettingsWrapper() { Properties = this }, _jsonSerializerOptions);
422422

423423
// Create directory if it doesn't exist
424-
IFileInfo file = _fileSystem.FileInfo.FromFileName(SettingsPath);
424+
IFileInfo file = _fileSystem.FileInfo.New(SettingsPath);
425425
file.Directory.Create();
426426

427427
// write string to file

‎src/modules/launcher/Plugins/Microsoft.Plugin.Folder.UnitTests/InternalQueryFolderTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void Query_ThrowsException_WhenCalledNull()
5151
[DataRow(@"c:", 2, 1, false, DisplayName = "Root without \\")]
5252
[DataRow(@"c:\", 2, 1, false, DisplayName = "Normal root")]
5353
[DataRow(@"c:\Test", 2, 2, false, DisplayName = "Select yourself")]
54-
[DataRow(@"c:\not-exist", 2, 1, false, DisplayName = "Folder not exist, return root")]
54+
[DataRow(@"c:\not-exist", 2, 0, false, DisplayName = "Folder not exist, return root")]
5555
[DataRow(@"c:\not-exist\not-exist2", 0, 0, false, DisplayName = "Folder not exist, return root")]
5656
[DataRow(@"c:\bla.t", 2, 1, false, DisplayName = "Partial match file")]
5757
[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
8888

8989
[DataTestMethod]
9090
[DataRow(@"c:\>", 3, 3, true, DisplayName = "Max Folder test recursive")]
91-
[DataRow(@"c:\Test>", 3, 3, true, DisplayName = "2 Folders recursive")]
92-
[DataRow(@"c:\not-exist>", 3, 3, true, DisplayName = "Folder not exist, return root recursive")]
91+
[DataRow(@"c:\Test>", 3, 0, true, DisplayName = "2 Folders recursive")]
92+
[DataRow(@"c:\not-exist>", 3, 0, true, DisplayName = "Folder not exist, return root recursive")]
9393
[DataRow(@"c:\not-exist\not-exist2>", 0, 0, false, DisplayName = "Folder not exist, return root recursive")]
9494
public void Query_Recursive_WhenCalled(string search, int folders, int files, bool truncated)
9595
{

‎src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Sources/QueryFileSystemInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public QueryFileSystemInfo(IDirectoryInfoFactory directoryInfoFactory, MatchType
2525
public IEnumerable<DisplayFileInfo> MatchFileSystemInfo(string search, string incompleteName, bool isRecursive)
2626
{
2727
// search folder and add results
28-
var directoryInfo = _directoryInfoFactory.FromDirectoryName(search);
28+
var directoryInfo = _directoryInfoFactory.New(search);
2929
var fileSystemInfos = directoryInfo.EnumerateFileSystemInfos(incompleteName, new EnumerationOptions
3030
{
3131
MatchType = _matchType,

‎src/modules/launcher/Plugins/Microsoft.Plugin.Program/ProgramSource.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class ProgramSource
2222

2323
public string Location { get; set; }
2424

25-
public string Name { get => name ?? FileSystem.DirectoryInfo.FromDirectoryName(Location).Name; set => name = value; }
25+
public string Name { get => name ?? FileSystem.DirectoryInfo.New(Location).Name; set => name = value; }
2626

2727
public bool Enabled { get; set; } = true;
2828

‎src/modules/launcher/Wox.Infrastructure/Helper.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public static void ValidateDataDirectory(string bundledDataDirectory, string dat
7171
}
7272
else
7373
{
74-
var time1 = FileInfo.FromFileName(bundledDataPath).LastWriteTimeUtc;
75-
var time2 = FileInfo.FromFileName(dataPath).LastWriteTimeUtc;
74+
var time1 = FileInfo.New(bundledDataPath).LastWriteTimeUtc;
75+
var time2 = FileInfo.New(dataPath).LastWriteTimeUtc;
7676
if (time1 != time2)
7777
{
7878
File.Copy(bundledDataPath, dataPath, true);

‎src/settings-ui/Settings.UI.Library/LanguageModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static string LoadSetting()
3030
{
3131
try
3232
{
33-
Stream inputStream = fileSystem.File.Open(file, FileMode.Open);
33+
FileSystemStream inputStream = fileSystem.File.Open(file, FileMode.Open);
3434
StreamReader reader = new StreamReader(inputStream);
3535
string data = reader.ReadToEnd();
3636
inputStream.Close();

‎src/settings-ui/Settings.UI.Library/UpdatingSettings.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static UpdatingSettings LoadSettings()
102102
{
103103
try
104104
{
105-
Stream inputStream = fileSystem.File.Open(file, FileMode.Open);
105+
FileSystemStream inputStream = fileSystem.File.Open(file, FileMode.Open);
106106
StreamReader reader = new StreamReader(inputStream);
107107
string data = reader.ReadToEnd();
108108
inputStream.Close();

‎src/settings-ui/Settings.UI.Library/Utilities/Helper.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.IO;
88
using System.IO.Abstractions;
99
using System.Linq;
10-
using System.Net.NetworkInformation;
1110
using System.Security.Principal;
1211

1312
using Microsoft.PowerToys.Settings.UI.Library.CustomAction;
@@ -63,7 +62,7 @@ public static IFileSystemWatcher GetFileWatcher(string moduleName, string fileNa
6362
FileSystem.Directory.CreateDirectory(path);
6463
}
6564

66-
var watcher = FileSystem.FileSystemWatcher.CreateNew();
65+
var watcher = FileSystem.FileSystemWatcher.New();
6766
watcher.Path = path;
6867
watcher.Filter = fileName;
6968
watcher.NotifyFilter = NotifyFilters.LastWrite;

‎src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeWhatsNew.xaml.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,15 @@ private static async Task<string> GetReleaseNotesMarkdown()
123123

124124
// Regex to remove installer hash sections from the release notes, since there'll be no Highlights section for hotfix releases.
125125
Regex removeHotfixHashRegex = new Regex(RemoveHotFixInstallerHashesRegex, RemoveInstallerHashesRegexOptions);
126-
126+
int counter = 0;
127127
foreach (var release in latestReleases)
128128
{
129129
releaseNotesHtmlBuilder.AppendLine("# " + release.Name);
130130
var notes = removeHashRegex.Replace(release.ReleaseNotes, "\r\n## Highlights");
131+
132+
// Add a unique counter to [github-current-release-work] to distinguish each release,
133+
// since this variable is used for all latest releases when they are merged.
134+
notes = notes.Replace("[github-current-release-work]", $"[github-current-release-work{++counter}]");
131135
notes = removeHotfixHashRegex.Replace(notes, string.Empty);
132136
releaseNotesHtmlBuilder.AppendLine(notes);
133137
releaseNotesHtmlBuilder.AppendLine("&nbsp;");

‎src/settings-ui/Settings.UI/SettingsXAML/Views/AwakePage.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public AwakePage()
5454

5555
var settingsPath = _settingsUtils.GetSettingsFilePath(_appName);
5656

57-
_fileSystemWatcher = _fileSystem.FileSystemWatcher.CreateNew();
57+
_fileSystemWatcher = _fileSystem.FileSystemWatcher.New();
5858
_fileSystemWatcher.Path = _fileSystem.Path.GetDirectoryName(settingsPath);
5959
_fileSystemWatcher.Filter = _fileSystem.Path.GetFileName(settingsPath);
6060
_fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.CreationTime;

0 commit comments

Comments
 (0)
Please sign in to comment.