[Refactor]Port C++/CX to C++/WinRT (#34198)

## Summary of the Pull Request
Removes all C++/CX code, replacing it with C++/WinRT.

## Detailed Description of the Pull Request / Additional comments
Removes all C++/CX code.
Renames interop namespaces to be better consumed by CsWinRT.
Standardizes all projects on net8.0-windows10.0.20348.0, which is a
requirement for C++/WinRT usage.
FileLocksmithLibInterop brought to stdcpplatest and static analysis
errors were corrected.
Removed now unneeded string conversion code from
FileLocksmithLibInterop.
Changed interop KeyboardHook to use a single hook across all instances.
Required because on C++/WinRT we don't have the .NET runtime to bind a
object instance to a delegate and be able to pass it to a C function
pointer argument (still no idea why this worked correctly on C++/CX to
be honest). This change actually makes us create less low level keyboard
hooks.
Changed some code that depended on arrays since WinRT/C++ returns null
instead of an empty array through the interface.

## Validation Steps Performed
Built and tested runtime.
This commit is contained in:
Jaime Bernardo
2024-08-08 15:26:43 +01:00
committed by GitHub
parent b16e82c837
commit fb5ed13386
136 changed files with 1511 additions and 1119 deletions

View File

@@ -11,8 +11,8 @@ using System.Threading;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using FileLocksmith.Interop;
using ManagedCommon;
using PowerToys.FileLocksmithLib.Interop;
namespace PowerToys.FileLocksmithUI.ViewModels
{
@@ -95,10 +95,14 @@ namespace PowerToys.FileLocksmithUI.ViewModels
_cancelProcessWatching = new CancellationTokenSource();
foreach (ProcessResult p in await FindProcesses(paths))
var processes_found = await FindProcesses(paths);
if (processes_found is not null)
{
Processes.Add(p);
WatchProcess(p, _cancelProcessWatching.Token);
foreach (ProcessResult p in processes_found)
{
Processes.Add(p);
WatchProcess(p, _cancelProcessWatching.Token);
}
}
IsLoading = false;
@@ -109,7 +113,7 @@ namespace PowerToys.FileLocksmithUI.ViewModels
var results = new List<ProcessResult>();
await Task.Run(() =>
{
results = NativeMethods.FindProcessesRecursive(paths).ToList();
results = NativeMethods.FindProcessesRecursive(paths)?.ToList();
});
return results;
}