Skip to content

Code Quality: Replaced stack-allocated GUIDs with RVA-inlined GUIDs #16993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -56,5 +56,6 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.8.2" />
<PackageVersion Include="MSTest.TestFramework" Version="3.8.2" />
<PackageVersion Include="Dongle.GuidRVAGen" Version="1.0.4" />
</ItemGroup>
</Project>
5 changes: 2 additions & 3 deletions src/Files.App.CsWin32/ComPtr`1.cs
Original file line number Diff line number Diff line change
@@ -56,10 +56,9 @@ public readonly ComPtr<U> As<U>() where U : unmanaged, IComIID
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly HRESULT CoCreateInstance<U>(CLSCTX dwClsContext = CLSCTX.CLSCTX_LOCAL_SERVER)
public readonly HRESULT CoCreateInstance(Guid* rclsid, IUnknown* pUnkOuter = null, CLSCTX dwClsContext = CLSCTX.CLSCTX_LOCAL_SERVER)
{
Guid iid = typeof(T).GUID, clsid = typeof(U).GUID;
return PInvoke.CoCreateInstance(&clsid, null, dwClsContext, &iid, (void**)this.GetAddressOf());
return PInvoke.CoCreateInstance(rclsid, pUnkOuter, dwClsContext, (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in T.Guid)), (void**)this.GetAddressOf());
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
1 change: 1 addition & 0 deletions src/Files.App.CsWin32/Files.App.CsWin32.csproj
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWin32" PrivateAssets="all" />
<PackageReference Include="Dongle.GuidRVAGen" />
</ItemGroup>

</Project>
24 changes: 5 additions & 19 deletions src/Files.App.CsWin32/IStorageProviderQuotaUI.cs
Original file line number Diff line number Diff line change
@@ -9,9 +9,11 @@

namespace Windows.Win32.System.WinRT
{
public unsafe struct IStorageProviderQuotaUI : IComIID
public unsafe partial struct IStorageProviderQuotaUI : IComIID
{
#pragma warning disable CS0649 // Field 'field' is never assigned to, and will always have its default value 'value'
private void** lpVtbl;
#pragma warning restore CS0649 // Field 'field' is never assigned to, and will always have its default value 'value'

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public HRESULT GetQuotaTotalInBytes(ulong* value)
@@ -25,23 +27,7 @@ public HRESULT GetQuotaUsedInBytes(ulong* value)
return ((delegate* unmanaged[Stdcall]<IStorageProviderQuotaUI*, ulong*, HRESULT>)(lpVtbl[8]))((IStorageProviderQuotaUI*)Unsafe.AsPointer(ref this), value);
}

public static ref readonly Guid Guid
{
get
{
// BA6295C3-312E-544F-9FD5-1F81B21F3649
ReadOnlySpan<byte> data =
[
0xC3, 0x95, 0x62, 0xBA,
0x2E, 0x31,
0x4F, 0x54,
0x9F, 0xD5,
0x1F, 0x81, 0xB2, 0x1F, 0x36, 0x49
];

Debug.Assert(data.Length == sizeof(Guid));
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
}
}
[GuidRVAGen.Guid("BA6295C3-312E-544F-9FD5-1F81B21F3649")]
public static partial ref readonly Guid Guid { get; }
}
}
24 changes: 5 additions & 19 deletions src/Files.App.CsWin32/IStorageProviderStatusUI.cs
Original file line number Diff line number Diff line change
@@ -9,33 +9,19 @@

namespace Windows.Win32.System.WinRT
{
public unsafe struct IStorageProviderStatusUI : IComIID
public unsafe partial struct IStorageProviderStatusUI : IComIID
{
#pragma warning disable CS0649 // Field 'field' is never assigned to, and will always have its default value 'value'
private void** lpVtbl;
#pragma warning restore CS0649 // Field 'field' is never assigned to, and will always have its default value 'value'

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public HRESULT GetQuotaUI(IStorageProviderQuotaUI** result)
{
return ((delegate* unmanaged[Stdcall]<IStorageProviderStatusUI*, IStorageProviderQuotaUI**, HRESULT>)lpVtbl[14])((IStorageProviderStatusUI*)Unsafe.AsPointer(ref this), result);
}

public static ref readonly Guid Guid
{
get
{
// d6b6a758-198d-5b80-977f-5ff73da33118
ReadOnlySpan<byte> data =
[
0x58, 0xa7, 0xb6, 0xd6,
0x8d, 0x19,
0x80, 0x5b,
0x97, 0x7f,
0x5f, 0xf7, 0x3d, 0xa3, 0x31, 0x18
];

Debug.Assert(data.Length == sizeof(Guid));
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
}
}
[GuidRVAGen.Guid("D6B6A758-198D-5B80-977F-5FF73DA33118")]
public static partial ref readonly Guid Guid { get; }
}
}
24 changes: 5 additions & 19 deletions src/Files.App.CsWin32/IStorageProviderStatusUISource.cs
Original file line number Diff line number Diff line change
@@ -9,33 +9,19 @@

namespace Windows.Win32.System.WinRT
{
public unsafe struct IStorageProviderStatusUISource : IComIID
public unsafe partial struct IStorageProviderStatusUISource : IComIID
{
#pragma warning disable CS0649 // Field 'field' is never assigned to, and will always have its default value 'value'
private void** lpVtbl;
#pragma warning restore CS0649 // Field 'field' is never assigned to, and will always have its default value 'value'

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public HRESULT GetStatusUI(IStorageProviderStatusUI** result)
{
return ((delegate* unmanaged[Stdcall]<IStorageProviderStatusUISource*, IStorageProviderStatusUI**, HRESULT>)lpVtbl[6])((IStorageProviderStatusUISource*)Unsafe.AsPointer(ref this), result);
}

public static ref readonly Guid Guid
{
get
{
// A306C249-3D66-5E70-9007-E43DF96051FF
ReadOnlySpan<byte> data =
[
0x49, 0xc2, 0x06, 0xa3,
0x66, 0x3d,
0x70, 0x5e,
0x90, 0x07,
0xe4, 0x3d, 0xf9, 0x60, 0x51, 0xff
];

Debug.Assert(data.Length == sizeof(Guid));
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
}
}
[GuidRVAGen.Guid("A306C249-3D66-5E70-9007-E43DF96051FF")]
public static partial ref readonly Guid Guid { get; }
}
}
24 changes: 5 additions & 19 deletions src/Files.App.CsWin32/IStorageProviderStatusUISourceFactory.cs
Original file line number Diff line number Diff line change
@@ -9,33 +9,19 @@

namespace Windows.Win32.System.WinRT
{
public unsafe struct IStorageProviderStatusUISourceFactory : IComIID
public unsafe partial struct IStorageProviderStatusUISourceFactory : IComIID
{
#pragma warning disable CS0649 // Field 'field' is never assigned to, and will always have its default value 'value'
private void** lpVtbl;
#pragma warning restore CS0649 // Field 'field' is never assigned to, and will always have its default value 'value'

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public HRESULT GetStatusUISource(nint syncRootId, IStorageProviderStatusUISource** result)
{
return ((delegate* unmanaged[Stdcall]<IStorageProviderStatusUISourceFactory*, nint, IStorageProviderStatusUISource**, HRESULT>)lpVtbl[6])((IStorageProviderStatusUISourceFactory*)Unsafe.AsPointer(ref this), syncRootId, result);
}

public static ref readonly Guid Guid
{
get
{
// 12E46B74-4E5A-58D1-A62F-0376E8EE7DD8
ReadOnlySpan<byte> data =
[
0x74, 0x6b, 0xe4, 0x12,
0x5a, 0x4e,
0xd1, 0x58,
0xa6, 0x2f,
0x03, 0x76, 0xe8, 0xee, 0x7d, 0xd8
];

Debug.Assert(data.Length == sizeof(Guid));
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
}
}
[GuidRVAGen.Guid("12E46B74-4E5A-58D1-A62F-0376E8EE7DD8")]
public static partial ref readonly Guid Guid { get; }
}
}
75 changes: 75 additions & 0 deletions src/Files.App.CsWin32/ManualGuid.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) Files Community
// Licensed under the MIT License.

using System;
using System.Runtime.CompilerServices;
using Windows.Win32.System.WinRT;

namespace Windows.Win32
{
public static unsafe partial class IID
{
public static Guid* IID_IStorageProviderStatusUISourceFactory
=> (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IStorageProviderStatusUISourceFactory.Guid));

[GuidRVAGen.Guid("000214E4-0000-0000-C000-000000000046")]
public static partial Guid* IID_IContextMenu { get; }

[GuidRVAGen.Guid("70629033-E363-4A28-A567-0DB78006E6D7")]
public static partial Guid* IID_IEnumShellItems { get; }

[GuidRVAGen.Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE")]
public static partial Guid* IID_IShellItem { get; }

[GuidRVAGen.Guid("7E9FB0D3-919F-4307-AB2E-9B1860310C93")]
public static partial Guid* IID_IShellItem2 { get; }

[GuidRVAGen.Guid("947AAB5F-0A5C-4C13-B4D6-4BF7836FC9F8")]
public static partial Guid* IID_IFileOperation { get; }

[GuidRVAGen.Guid("D57C7288-D4AD-4768-BE02-9D969532D960")]
public static partial Guid* IID_IFileOpenDialog { get; }

[GuidRVAGen.Guid("84BCCD23-5FDE-4CDB-AEA4-AF64B83D78AB")]
public static partial Guid* IID_IFileSaveDialog { get; }

[GuidRVAGen.Guid("B92B56A9-8B55-4E14-9A89-0199BBB6F93B")]
public static partial Guid* IID_IDesktopWallpaper { get; }

[GuidRVAGen.Guid("2E941141-7F97-4756-BA1D-9DECDE894A3D")]
public static partial Guid* IID_IApplicationActivationManager { get; }
}

public static unsafe partial class CLSID
{
[GuidRVAGen.Guid("3AD05575-8857-4850-9277-11B85BDB8E09")]
public static partial Guid* CLSID_FileOperation { get; }

[GuidRVAGen.Guid("DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7")]
public static partial Guid* CLSID_FileOpenDialog { get; }

[GuidRVAGen.Guid("C0B4E2F3-BA21-4773-8DBA-335EC946EB8B")]
public static partial Guid* CLSID_FileSaveDialog { get; }

[GuidRVAGen.Guid("C2CF3110-460E-4FC1-B9D0-8A1C0C9CC4BD")]
public static partial Guid* CLSID_DesktopWallpaper { get; }

[GuidRVAGen.Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")]
public static partial Guid* CLSID_ApplicationActivationManager { get; }
}

public static unsafe partial class BHID
{
[GuidRVAGen.Guid("3981E225-F559-11D3-8E3A-00C04F6837D5")]
public static partial Guid* BHID_SFUIObject { get; }

[GuidRVAGen.Guid("94F60519-2850-4924-AA5A-D15E84868039")]
public static partial Guid* BHID_EnumItems { get; }
}

public static unsafe partial class FOLDERID
{
[GuidRVAGen.Guid("B7534046-3ECB-4C18-BE4E-64CD4CB7D6AC")]
public static partial Guid* FOLDERID_RecycleBinFolder { get; }
}
}
15 changes: 4 additions & 11 deletions src/Files.App/Services/Storage/StorageTrashBinService.cs
Original file line number Diff line number Diff line change
@@ -102,21 +102,15 @@ private unsafe bool RestoreAllTrashesInternal()
{
// Get IShellItem for Recycle Bin folder
using ComPtr<IShellItem> pRecycleBinFolderShellItem = default;
var recycleBinFolderId = PInvoke.FOLDERID_RecycleBinFolder;
var shellItemGuid = typeof(IShellItem).GUID;
HRESULT hr = PInvoke.SHGetKnownFolderItem(&recycleBinFolderId, KNOWN_FOLDER_FLAG.KF_FLAG_DEFAULT, HANDLE.Null, &shellItemGuid, (void**)pRecycleBinFolderShellItem.GetAddressOf());
HRESULT hr = PInvoke.SHGetKnownFolderItem(FOLDERID.FOLDERID_RecycleBinFolder, KNOWN_FOLDER_FLAG.KF_FLAG_DEFAULT, HANDLE.Null, IID.IID_IShellItem, (void**)pRecycleBinFolderShellItem.GetAddressOf());

// Get IEnumShellItems for Recycle Bin folder
using ComPtr<IEnumShellItems> pEnumShellItems = default;
Guid enumShellItemGuid = typeof(IEnumShellItems).GUID;
var enumItemsBHID = PInvoke.BHID_EnumItems;
hr = pRecycleBinFolderShellItem.Get()->BindToHandler(null, &enumItemsBHID, &enumShellItemGuid, (void**)pEnumShellItems.GetAddressOf());
hr = pRecycleBinFolderShellItem.Get()->BindToHandler(null, BHID.BHID_EnumItems, IID.IID_IEnumShellItems, (void**)pEnumShellItems.GetAddressOf());

// Initialize how to perform the operation
using ComPtr<IFileOperation> pFileOperation = default;
var fileOperationIid = typeof(IFileOperation).GUID;
var fileOperationInstanceIid = typeof(FileOperation).GUID;
hr = PInvoke.CoCreateInstance(&fileOperationInstanceIid, null, CLSCTX.CLSCTX_LOCAL_SERVER, &fileOperationIid, (void**)pFileOperation.GetAddressOf());
hr = PInvoke.CoCreateInstance(CLSID.CLSID_FileOperation, null, CLSCTX.CLSCTX_LOCAL_SERVER, IID.IID_IFileOperation, (void**)pFileOperation.GetAddressOf());
hr = pFileOperation.Get()->SetOperationFlags(FILEOPERATION_FLAGS.FOF_NO_UI);
hr = pFileOperation.Get()->SetOwnerWindow(new(MainWindow.Instance.WindowHandle));

@@ -125,8 +119,7 @@ private unsafe bool RestoreAllTrashesInternal()
{
// Get the original path
using ComPtr<IShellItem2> pShellItem2 = default;
var shellItem2Iid = typeof(IShellItem2).GUID;
hr = pShellItem.Get()->QueryInterface(&shellItem2Iid, (void**)pShellItem2.GetAddressOf());
hr = pShellItem.Get()->QueryInterface(IID.IID_IShellItem2, (void**)pShellItem2.GetAddressOf());
hr = PInvoke.PSGetPropertyKeyFromName("System.Recycle.DeletedFrom", out var originalPathPropertyKey);
hr = pShellItem2.Get()->GetString(originalPathPropertyKey, out var szOriginalPath);

30 changes: 4 additions & 26 deletions src/Files.App/Services/Windows/WindowsDialogService.cs
Original file line number Diff line number Diff line change
@@ -23,17 +23,7 @@ public unsafe bool Open_FileOpenDialog(nint hWnd, bool pickFoldersOnly, string[]
try
{
using ComPtr<IFileOpenDialog> pDialog = default;
var dialogInstanceIid = typeof(FileOpenDialog).GUID;
var dialogIid = typeof(IFileOpenDialog).GUID;

// Get a new instance of the dialog
HRESULT hr = PInvoke.CoCreateInstance(
&dialogInstanceIid,
null,
CLSCTX.CLSCTX_INPROC_SERVER,
&dialogIid,
(void**)pDialog.GetAddressOf())
.ThrowOnFailure();
HRESULT hr = pDialog.CoCreateInstance(CLSID.CLSID_FileOpenDialog, null, CLSCTX.CLSCTX_INPROC_SERVER).ThrowOnFailure();

if (filters.Length is not 0 && filters.Length % 2 is 0)
{
@@ -56,13 +46,12 @@ public unsafe bool Open_FileOpenDialog(nint hWnd, bool pickFoldersOnly, string[]

// Get the default shell folder (My Computer)
using ComPtr<IShellItem> pDefaultFolderShellItem = default;
var shellItemIid = typeof(IShellItem).GUID;
fixed (char* pszDefaultFolderPath = Environment.GetFolderPath(defaultFolder))
{
hr = PInvoke.SHCreateItemFromParsingName(
pszDefaultFolderPath,
null,
&shellItemIid,
IID.IID_IShellItem,
(void**)pDefaultFolderShellItem.GetAddressOf())
.ThrowOnFailure();
}
@@ -104,17 +93,7 @@ public unsafe bool Open_FileSaveDialog(nint hWnd, bool pickFoldersOnly, string[]
try
{
using ComPtr<IFileSaveDialog> pDialog = default;
var dialogInstanceIid = typeof(FileSaveDialog).GUID;
var dialogIid = typeof(IFileSaveDialog).GUID;

// Get a new instance of the dialog
HRESULT hr = PInvoke.CoCreateInstance(
&dialogInstanceIid,
null,
CLSCTX.CLSCTX_INPROC_SERVER,
&dialogIid,
(void**)pDialog.GetAddressOf())
.ThrowOnFailure();
HRESULT hr = pDialog.CoCreateInstance(CLSID.CLSID_FileSaveDialog, null, CLSCTX.CLSCTX_INPROC_SERVER).ThrowOnFailure();

if (filters.Length is not 0 && filters.Length % 2 is 0)
{
@@ -137,13 +116,12 @@ public unsafe bool Open_FileSaveDialog(nint hWnd, bool pickFoldersOnly, string[]

// Get the default shell folder (My Computer)
using ComPtr<IShellItem> pDefaultFolderShellItem = default;
var shellItemIid = typeof(IShellItem).GUID;
fixed (char* pszDefaultFolderPath = Environment.GetFolderPath(defaultFolder))
{
hr = PInvoke.SHCreateItemFromParsingName(
pszDefaultFolderPath,
null,
&shellItemIid,
IID.IID_IShellItem,
(void**)pDefaultFolderShellItem.GetAddressOf())
.ThrowOnFailure();
}
14 changes: 4 additions & 10 deletions src/Files.App/Services/Windows/WindowsRecentItemsService.cs
Original file line number Diff line number Diff line change
@@ -115,10 +115,8 @@ public unsafe bool Remove(RecentItem item)
{
try
{
var bhid = PInvoke.BHID_SFUIObject;
var contextMenuIid = typeof(IContextMenu).GUID;
using ComPtr<IContextMenu> pContextMenu = default;
HRESULT hr = item.ShellItem.Get()->BindToHandler(null, &bhid, &contextMenuIid, (void**)pContextMenu.GetAddressOf());
HRESULT hr = item.ShellItem.Get()->BindToHandler(null, BHID.BHID_SFUIObject, IID.IID_IContextMenu, (void**)pContextMenu.GetAddressOf());
HMENU hMenu = PInvoke.CreatePopupMenu();
hr = pContextMenu.Get()->QueryContextMenu(hMenu, 0, 1, 0x7FFF, PInvoke.CMF_OPTIMIZEFORINVOKE);

@@ -191,16 +189,13 @@ private unsafe bool UpdateRecentItems(bool isFolder)
: "Shell:::{679F85CB-0220-4080-B29B-5540CC05AAB6}"; // Quick Access folder (recent files)

// Get IShellItem of the shell folder
var shellItemIid = typeof(IShellItem).GUID;
using ComPtr<IShellItem> pFolderShellItem = default;
fixed (char* pszFolderShellPath = szFolderShellPath)
hr = PInvoke.SHCreateItemFromParsingName(pszFolderShellPath, null, &shellItemIid, (void**)pFolderShellItem.GetAddressOf());
hr = PInvoke.SHCreateItemFromParsingName(pszFolderShellPath, null, IID.IID_IShellItem, (void**)pFolderShellItem.GetAddressOf());

// Get IEnumShellItems of the quick access shell folder
var enumItemsBHID = PInvoke.BHID_EnumItems;
Guid enumShellItemIid = typeof(IEnumShellItems).GUID;
using ComPtr<IEnumShellItems> pEnumShellItems = default;
hr = pFolderShellItem.Get()->BindToHandler(null, &enumItemsBHID, &enumShellItemIid, (void**)pEnumShellItems.GetAddressOf());
hr = pFolderShellItem.Get()->BindToHandler(null, BHID.BHID_EnumItems, IID.IID_IEnumShellItems, (void**)pEnumShellItems.GetAddressOf());

// Enumerate recent items and populate the list
int index = 0;
@@ -233,9 +228,8 @@ private unsafe bool UpdateRecentItems(bool isFolder)
fileName = string.IsNullOrEmpty(fileNameWithoutExtension) ? SystemIO.Path.GetFileName(fileName) : fileNameWithoutExtension;

// Get the date last modified
var shellItem2Iid = typeof(IShellItem2).GUID;
using ComPtr<IShellItem2> pShellItem2 = default;
hr = pShellItem.Get()->QueryInterface(&shellItem2Iid, (void**)pShellItem2.GetAddressOf());
hr = pShellItem.Get()->QueryInterface(IID.IID_IShellItem2, (void**)pShellItem2.GetAddressOf());
hr = PInvoke.PSGetPropertyKeyFromName("System.DateModified", out var propertyKey);
hr = pShellItem2.Get()->GetString(propertyKey, out var szPropertyValue);
if (DateTime.TryParse(szPropertyValue.ToString(), out var lastModified))
4 changes: 2 additions & 2 deletions src/Files.App/Services/Windows/WindowsWallpaperService.cs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ public unsafe void SetDesktopWallpaper(string szPath)
{
// Instantiate IDesktopWallpaper
using ComPtr<IDesktopWallpaper> pDesktopWallpaper = default;
HRESULT hr = pDesktopWallpaper.CoCreateInstance<DesktopWallpaper>().ThrowOnFailure();
HRESULT hr = pDesktopWallpaper.CoCreateInstance(CLSID.CLSID_DesktopWallpaper).ThrowOnFailure();

// Get total count of all available monitors
hr = pDesktopWallpaper.Get()->GetMonitorDevicePathCount(out var dwMonitorCount).ThrowOnFailure();
@@ -45,7 +45,7 @@ public unsafe void SetDesktopSlideshow(string[] aszPaths)
{
// Instantiate IDesktopWallpaper
using ComPtr<IDesktopWallpaper> pDesktopWallpaper = default;
HRESULT hr = pDesktopWallpaper.CoCreateInstance<DesktopWallpaper>().ThrowOnFailure();
HRESULT hr = pDesktopWallpaper.CoCreateInstance(CLSID.CLSID_DesktopWallpaper).ThrowOnFailure();

uint dwCount = (uint)aszPaths.Length;
ITEMIDLIST** ppItemIdList = stackalloc ITEMIDLIST*[aszPaths.Length];
2 changes: 1 addition & 1 deletion src/Files.App/Utils/Shell/LaunchHelper.cs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ public static class LaunchHelper
public unsafe static void LaunchSettings(string page)
{
using ComPtr<IApplicationActivationManager> pApplicationActivationManager = default;
pApplicationActivationManager.CoCreateInstance<Shell32.ApplicationActivationManager>();
pApplicationActivationManager.CoCreateInstance(CLSID.CLSID_ApplicationActivationManager);

pApplicationActivationManager.Get()->ActivateApplication(
"windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel",
3 changes: 1 addition & 2 deletions src/Files.App/Utils/Storage/Helpers/SyncRootHelpers.cs
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@ private static unsafe (bool Success, ulong Capacity, ulong Used) GetSyncRootQuot
!Guid.TryParse(factoryClsidString, out var factoryClsid))
return (false, 0, 0);

HRESULT hr = default;
ulong ulTotalSize = 0ul, ulUsedSize = 0ul;
using ComPtr<IStorageProviderStatusUISourceFactory> pStorageProviderStatusUISourceFactory = default;
using ComPtr<IStorageProviderStatusUISource> pStorageProviderStatusUISource = default;
@@ -31,7 +30,7 @@ private static unsafe (bool Success, ulong Capacity, ulong Used) GetSyncRootQuot
&factoryClsid,
null,
CLSCTX.CLSCTX_LOCAL_SERVER,
(Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IStorageProviderStatusUISourceFactory.Guid)),
IID.IID_IStorageProviderStatusUISourceFactory,
(void**)pStorageProviderStatusUISourceFactory.GetAddressOf()).ThrowIfFailedOnDebug().Failed)
return (false, 0, 0);


Unchanged files with check annotations Beta

private static void OnOneRowModeEnabledChanged(DependencyObject d, object newValue)
{
var self = d as AdaptiveGridView;
self.DetermineOneRowMode();

Check warning on line 65 in src/Files.App.Controls/AdaptiveGridView/AdaptiveGridView.Properties.cs

GitHub Actions / build (Debug, arm64)

Dereference of a possibly null reference.

Check warning on line 65 in src/Files.App.Controls/AdaptiveGridView/AdaptiveGridView.Properties.cs

GitHub Actions / build (Release, x64)

Dereference of a possibly null reference.

Check warning on line 65 in src/Files.App.Controls/AdaptiveGridView/AdaptiveGridView.Properties.cs

GitHub Actions / build (Debug, x64)

Dereference of a possibly null reference.
}
private static void DesiredWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var self = d as AdaptiveGridView;
self.RecalculateLayout(self.ActualWidth);

Check warning on line 71 in src/Files.App.Controls/AdaptiveGridView/AdaptiveGridView.Properties.cs

GitHub Actions / build (Debug, arm64)

Dereference of a possibly null reference.

Check warning on line 71 in src/Files.App.Controls/AdaptiveGridView/AdaptiveGridView.Properties.cs

GitHub Actions / build (Debug, x64)

Dereference of a possibly null reference.
}
private static void OnStretchContentForSingleRowPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
SetHasContent( false );
}
UpdateContent( newContent );

Check warning on line 175 in src/Files.App.Controls/Toolbar/ToolbarToggleButton/ToolbarToggleButton.cs

GitHub Actions / build (Debug, arm64)

Possible null reference argument for parameter 'newContent' in 'void ToolbarToggleButton.UpdateContent(object newContent)'.

Check warning on line 175 in src/Files.App.Controls/Toolbar/ToolbarToggleButton/ToolbarToggleButton.cs

GitHub Actions / build (Release, x64)

Possible null reference argument for parameter 'newContent' in 'void ToolbarToggleButton.UpdateContent(object newContent)'.

Check warning on line 175 in src/Files.App.Controls/Toolbar/ToolbarToggleButton/ToolbarToggleButton.cs

GitHub Actions / build (Release, arm64)

Possible null reference argument for parameter 'newContent' in 'void ToolbarToggleButton.UpdateContent(object newContent)'.

Check warning on line 175 in src/Files.App.Controls/Toolbar/ToolbarToggleButton/ToolbarToggleButton.cs

GitHub Actions / build (Debug, x64)

Possible null reference argument for parameter 'newContent' in 'void ToolbarToggleButton.UpdateContent(object newContent)'.
}
#endregion
var newDocument = context.Document.WithSyntaxRoot(newRoot);
context.RegisterCodeFix(
CodeAction.Create(

Check warning on line 57 in src/Files.Core.SourceGenerator/CodeFixProviders/StringsPropertyCodeFixProvider.cs

GitHub Actions / build (Debug, arm64)

Provide an explicit argument for optional parameter 'equivalenceKey', which is non-null and unique for each kind of code action created by this fixer

Check warning on line 57 in src/Files.Core.SourceGenerator/CodeFixProviders/StringsPropertyCodeFixProvider.cs

GitHub Actions / build (Release, x64)

Provide an explicit argument for optional parameter 'equivalenceKey', which is non-null and unique for each kind of code action created by this fixer

Check warning on line 57 in src/Files.Core.SourceGenerator/CodeFixProviders/StringsPropertyCodeFixProvider.cs

GitHub Actions / build (Release, arm64)

Provide an explicit argument for optional parameter 'equivalenceKey', which is non-null and unique for each kind of code action created by this fixer

Check warning on line 57 in src/Files.Core.SourceGenerator/CodeFixProviders/StringsPropertyCodeFixProvider.cs

GitHub Actions / build (Debug, x64)

Provide an explicit argument for optional parameter 'equivalenceKey', which is non-null and unique for each kind of code action created by this fixer
CodeFixProviderTitle,
c => Task.FromResult(newDocument),
null),
/// <summary>
/// Analyzer that detects if string literals can be replaced with constants from the <c>Strings</c> class.
/// </summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]

Check warning on line 12 in src/Files.Core.SourceGenerator/Analyzers/StringsPropertyAnalyzer.cs

GitHub Actions / build (Debug, arm64)

This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)

Check warning on line 12 in src/Files.Core.SourceGenerator/Analyzers/StringsPropertyAnalyzer.cs

GitHub Actions / build (Release, x64)

This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)

Check warning on line 12 in src/Files.Core.SourceGenerator/Analyzers/StringsPropertyAnalyzer.cs

GitHub Actions / build (Release, arm64)

This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)

Check warning on line 12 in src/Files.Core.SourceGenerator/Analyzers/StringsPropertyAnalyzer.cs

GitHub Actions / build (Debug, x64)

This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
internal sealed class StringsPropertyAnalyzer : DiagnosticAnalyzer
{
/// <summary>
/// <summary>
/// Generates properties for strings based on resource files.
/// </summary>
[Generator]

Check warning on line 13 in src/Files.Core.SourceGenerator/Generators/StringsPropertyGenerator.cs

GitHub Actions / build (Debug, arm64)

This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)

Check warning on line 13 in src/Files.Core.SourceGenerator/Generators/StringsPropertyGenerator.cs

GitHub Actions / build (Release, x64)

This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)

Check warning on line 13 in src/Files.Core.SourceGenerator/Generators/StringsPropertyGenerator.cs

GitHub Actions / build (Release, arm64)

This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)

Check warning on line 13 in src/Files.Core.SourceGenerator/Generators/StringsPropertyGenerator.cs

GitHub Actions / build (Debug, x64)

This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
internal sealed class StringsPropertyGenerator : IIncrementalGenerator
{
// Static HashSet to track generated file names
/// <summary>
/// A generator for serializing/deserializing objects to/from the Windows Registry using attributes.
/// </summary>
[Generator]

Check warning on line 9 in src/Files.Core.SourceGenerator/Generators/RegistrySerializationGenerator.cs

GitHub Actions / build (Debug, arm64)

This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)

Check warning on line 9 in src/Files.Core.SourceGenerator/Generators/RegistrySerializationGenerator.cs

GitHub Actions / build (Release, x64)

This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)

Check warning on line 9 in src/Files.Core.SourceGenerator/Generators/RegistrySerializationGenerator.cs

GitHub Actions / build (Release, arm64)

This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)

Check warning on line 9 in src/Files.Core.SourceGenerator/Generators/RegistrySerializationGenerator.cs

GitHub Actions / build (Debug, x64)

This compiler extension should not be implemented in an assembly containing a reference to Microsoft.CodeAnalysis.Workspaces. The Microsoft.CodeAnalysis.Workspaces assembly is not provided during command line compilation scenarios, so references to it could cause the compiler extension to behave unpredictably. (https://github.com/dotnet/roslyn-analyzers/blob/main/docs/rules/RS1038.md)
internal sealed class RegistrySerializationGenerator : IIncrementalGenerator
{
/// <summary>
GetKeyState
CreateDirectoryFromApp
WNetCancelConnection2
NET_USE_CONNECT_FLAGS

Check warning on line 48 in src/Files.App.CsWin32/NativeMethods.txt

GitHub Actions / build (Debug, arm64)

Method, type or constant "NET_USE_CONNECT_FLAGS" not found

Check warning on line 48 in src/Files.App.CsWin32/NativeMethods.txt

GitHub Actions / build (Release, x64)

Method, type or constant "NET_USE_CONNECT_FLAGS" not found

Check warning on line 48 in src/Files.App.CsWin32/NativeMethods.txt

GitHub Actions / build (Release, arm64)

Method, type or constant "NET_USE_CONNECT_FLAGS" not found

Check warning on line 48 in src/Files.App.CsWin32/NativeMethods.txt

GitHub Actions / build (Debug, x64)

Method, type or constant "NET_USE_CONNECT_FLAGS" not found
NETRESOURCEW
WNetAddConnection3
CREDENTIALW
SetEntriesInAcl
ACL_SIZE_INFORMATION
DeleteAce
EXPLICIT_ACCESS

Check warning on line 81 in src/Files.App.CsWin32/NativeMethods.txt

GitHub Actions / build (Debug, arm64)

Method, type or constant "EXPLICIT_ACCESS" not found. Did you mean or "EXPLICIT_ACCESS_A" or "EXPLICIT_ACCESS_W"?

Check warning on line 81 in src/Files.App.CsWin32/NativeMethods.txt

GitHub Actions / build (Release, x64)

Method, type or constant "EXPLICIT_ACCESS" not found. Did you mean or "EXPLICIT_ACCESS_A" or "EXPLICIT_ACCESS_W"?

Check warning on line 81 in src/Files.App.CsWin32/NativeMethods.txt

GitHub Actions / build (Release, arm64)

Method, type or constant "EXPLICIT_ACCESS" not found. Did you mean or "EXPLICIT_ACCESS_A" or "EXPLICIT_ACCESS_W"?

Check warning on line 81 in src/Files.App.CsWin32/NativeMethods.txt

GitHub Actions / build (Debug, x64)

Method, type or constant "EXPLICIT_ACCESS" not found. Did you mean or "EXPLICIT_ACCESS_A" or "EXPLICIT_ACCESS_W"?
ACCESS_ALLOWED_ACE
LookupAccountSid
GetComputerName
CoTaskMemFree
QueryDosDevice
DeviceIoControl
GetLastError

Check warning on line 137 in src/Files.App.CsWin32/NativeMethods.txt

GitHub Actions / build (Debug, arm64)

This API will not be generated. Do not generate GetLastError. Call Marshal.GetLastWin32Error() instead. Learn more from https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshal.getlastwin32error

Check warning on line 137 in src/Files.App.CsWin32/NativeMethods.txt

GitHub Actions / build (Release, x64)

This API will not be generated. Do not generate GetLastError. Call Marshal.GetLastWin32Error() instead. Learn more from https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshal.getlastwin32error

Check warning on line 137 in src/Files.App.CsWin32/NativeMethods.txt

GitHub Actions / build (Release, arm64)

This API will not be generated. Do not generate GetLastError. Call Marshal.GetLastWin32Error() instead. Learn more from https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshal.getlastwin32error

Check warning on line 137 in src/Files.App.CsWin32/NativeMethods.txt

GitHub Actions / build (Debug, x64)

This API will not be generated. Do not generate GetLastError. Call Marshal.GetLastWin32Error() instead. Learn more from https://docs.microsoft.com/dotnet/api/system.runtime.interopservices.marshal.getlastwin32error
CreateFile
GetVolumeInformation
COMPRESSION_FORMAT
_ = PInvoke.RoInitialize(RO_INIT_TYPE.RO_INIT_MULTITHREADED);
var classIds = typeof(Program).Assembly.GetTypes()

Check warning on line 28 in src/Files.App.Server/Program.cs

GitHub Actions / build (Release, x64)

Using member 'System.Reflection.Assembly.GetTypes()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed.

Check warning on line 28 in src/Files.App.Server/Program.cs

GitHub Actions / build (Release, arm64)

Using member 'System.Reflection.Assembly.GetTypes()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed.
.Where(t => t.IsSealed && t.IsPublic && t.IsClass)
.Select(t => t.FullName!)
.Where(name => name.StartsWith("Files.App.Server.", StringComparison.Ordinal))
/// <summary>
/// Initializes a new instance of the <see cref="BladeItem"/> class.
/// </summary>
public BladeItem()

Check warning on line 18 in src/Files.App.Controls/BladeView/BladeItem.cs

GitHub Actions / build (Release, arm64)

Non-nullable field '_closeButton' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
{
DefaultStyleKey = typeof(BladeItem);
}