Skip to content

Commit 5aa072c

Browse files
authored
Code Quality: Added IsAotCompatible to some class library projects (#17123)
1 parent 4fa3d80 commit 5aa072c

File tree

10 files changed

+33
-77
lines changed

10 files changed

+33
-77
lines changed

src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<Platforms>x86;x64;ARM64</Platforms>
1111
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
1212
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
13+
<IsAotCompatible>true</IsAotCompatible>
1314
</PropertyGroup>
1415

1516
<PropertyGroup>

src/Files.App.CsWin32/Files.App.CsWin32.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<Configurations>Debug;Release</Configurations>
1010
<Platforms>x86;x64;arm64</Platforms>
1111
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
12+
<IsAotCompatible>true</IsAotCompatible>
1213
</PropertyGroup>
1314

1415
<ItemGroup>

src/Files.App.CsWin32/NativeMethods.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ RemoveDirectoryFromApp
4545
GetKeyState
4646
CreateDirectoryFromApp
4747
WNetCancelConnection2
48-
NET_USE_CONNECT_FLAGS
4948
NETRESOURCEW
5049
WNetAddConnection3
5150
CREDENTIALW
@@ -78,7 +77,6 @@ GetAce
7877
SetEntriesInAcl
7978
ACL_SIZE_INFORMATION
8079
DeleteAce
81-
EXPLICIT_ACCESS
8280
ACCESS_ALLOWED_ACE
8381
LookupAccountSid
8482
GetComputerName
@@ -133,7 +131,6 @@ ShellExecuteEx
133131
CoTaskMemFree
134132
QueryDosDevice
135133
DeviceIoControl
136-
GetLastError
137134
CreateFile
138135
GetVolumeInformation
139136
COMPRESSION_FORMAT

src/Files.App.Storage/Files.App.Storage.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<Platforms>x86;x64;arm64</Platforms>
1111
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
1212
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
13+
<IsAotCompatible>true</IsAotCompatible>
1314
</PropertyGroup>
1415

1516
<ItemGroup>

src/Files.App.Storage/Storables/WindowsStorage/WindowsStorableHelpers.Icon.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public unsafe static HRESULT TryGetThumbnail(this IWindowsStorable storable, int
4444
{
4545
thumbnailData = null;
4646

47-
using ComPtr<IShellItemImageFactory> pShellItemImageFactory = storable.ThisPtr.As<IShellItemImageFactory>();
47+
using ComPtr<IShellItemImageFactory> pShellItemImageFactory = default;
48+
storable.ThisPtr.As(pShellItemImageFactory.GetAddressOf());
4849
if (pShellItemImageFactory.IsNull)
4950
return HRESULT.E_NOINTERFACE;
5051

src/Files.App.Storage/Watchers/RecycleBinWatcher.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Files.App.Storage.Watchers
88
{
9+
[Obsolete]
910
public class RecycleBinWatcher : ITrashWatcher
1011
{
1112
private readonly List<SystemIO.FileSystemWatcher> _watchers = [];

src/Files.Core.Storage/Files.Core.Storage.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<Configurations>Debug;Release</Configurations>
99
<Platforms>x86;x64;arm64</Platforms>
1010
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
11+
<IsAotCompatible>true</IsAotCompatible>
1112
</PropertyGroup>
1213

1314
<ItemGroup>

src/Files.Shared/Files.Shared.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<Configurations>Debug;Release</Configurations>
99
<Platforms>x86;x64;arm64</Platforms>
1010
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
11+
<IsAotCompatible>true</IsAotCompatible>
1112
</PropertyGroup>
1213

1314
<ItemGroup>

src/Files.Shared/Helpers/PathHelpers.cs

Lines changed: 13 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -17,77 +17,28 @@ public static string Combine(string folder, string name)
1717
return folder.Contains('/') ? Path.Combine(folder, name).Replace('\\', '/') : Path.Combine(folder, name);
1818
}
1919

20-
public static string FormatName(string path)
21-
{
22-
string fileName;
23-
string rootPath = Path.GetPathRoot(path) ?? string.Empty;
24-
25-
if (rootPath == path &&
26-
( path.StartsWith(@"\\") ||
27-
(new DriveInfo(path).DriveType == System.IO.DriveType.Network)
28-
)
29-
)
30-
{
31-
// Network Share path
32-
fileName = path.Substring(path.LastIndexOf(@"\", StringComparison.Ordinal) + 1);
33-
}
34-
else if (rootPath == path)
35-
{
36-
// Drive path
37-
fileName = path;
38-
}
39-
else
40-
{
41-
// Standard file name
42-
fileName = Path.GetFileName(path);
43-
}
44-
45-
// Check for link file name
46-
if (FileExtensionHelpers.IsShortcutOrUrlFile(fileName))
47-
fileName = fileName.Remove(fileName.Length - 4);
48-
49-
return fileName;
50-
}
51-
52-
/// <summary>
53-
/// Determines whether the <paramref name="path"/> points to any special system folders.
54-
/// </summary>
55-
/// <remarks>
56-
/// The term "Special folder" refers to any folders that may be natively supported by a certain platform (e.g. Libraries).
57-
/// </remarks>
58-
/// <param name="path">The path to a folder to check.</param>
59-
/// <returns>If the path points to a special folder, returns true; otherwise false.</returns>
60-
public static bool IsSpecialFolder(string path)
61-
{
62-
foreach (Environment.SpecialFolder specialFolder in Enum.GetValues(typeof(Environment.SpecialFolder)))
63-
{
64-
var specialFolderPath = Environment.GetFolderPath(specialFolder);
65-
if (string.Equals(specialFolderPath, path, StringComparison.OrdinalIgnoreCase))
66-
return true;
67-
}
68-
69-
return false;
70-
}
71-
7220
public static bool TryGetFullPath(string commandName, out string fullPath)
7321
{
7422
fullPath = string.Empty;
7523
try
7624
{
77-
var p = new Process();
78-
p.StartInfo = new ProcessStartInfo
25+
var p = new Process
7926
{
80-
UseShellExecute = false,
81-
CreateNoWindow = true,
82-
FileName = "where.exe",
83-
Arguments = commandName,
84-
RedirectStandardOutput = true
27+
StartInfo = new ProcessStartInfo
28+
{
29+
UseShellExecute = false,
30+
CreateNoWindow = true,
31+
FileName = "where.exe",
32+
Arguments = commandName,
33+
RedirectStandardOutput = true
34+
}
8535
};
36+
8637
p.Start();
38+
8739
var output = p.StandardOutput.ReadToEnd();
8840
p.WaitForExit(1000);
8941

90-
9142
if (p.ExitCode != 0)
9243
return false;
9344

@@ -97,16 +48,17 @@ public static bool TryGetFullPath(string commandName, out string fullPath)
9748
if (FileExtensionHelpers.IsExecutableFile(line))
9849
{
9950
fullPath = line;
51+
10052
return true;
10153
}
10254
}
55+
10356
return false;
10457
}
10558
catch (Exception)
10659
{
10760
return false;
10861
}
109-
11062
}
11163
}
11264
}

src/Files.Shared/Utils/IAsyncInitialize.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
namespace Files.Shared.Utils
88
{
9-
/// <summary>
10-
/// Allows an object to be initialized asynchronously.
11-
/// </summary>
12-
public interface IAsyncInitialize
13-
{
14-
/// <summary>
15-
/// Initializes resources and prepares them for use.
16-
/// </summary>
17-
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that cancels this action.</param>
18-
/// <returns>A <see cref="Task"/> that represents the asynchronous operation.</returns>
19-
Task InitAsync(CancellationToken cancellationToken = default);
20-
}
9+
/// <summary>
10+
/// Allows an object to be initialized asynchronously.
11+
/// </summary>
12+
public interface IAsyncInitialize
13+
{
14+
/// <summary>
15+
/// Initializes resources and prepares them for use.
16+
/// </summary>
17+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that cancels this action.</param>
18+
/// <returns>A <see cref="Task"/> that represents the asynchronous operation.</returns>
19+
Task InitAsync(CancellationToken cancellationToken = default);
20+
}
2121
}

0 commit comments

Comments
 (0)