[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

@@ -104,7 +104,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
private static string DefaultPowertoysVersion()
{
return interop.CommonManaged.GetProductVersion();
return global::PowerToys.Interop.CommonManaged.GetProductVersion();
}
// This function is to implement the ISettingsConfig interface.

View File

@@ -3,7 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using interop;
using PowerToys.Interop;
namespace Microsoft.PowerToys.Settings.UI.Library
{

View File

@@ -4,9 +4,8 @@
Condition="exists('$(SolutionDir)src\Common.SelfContained.props')"
Project="$(SolutionDir)src\Common.SelfContained.props" />
<PropertyGroup>
<TargetFrameworks>net8.0-windows</TargetFrameworks>
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
<Description>PowerToys Settings UI Library</Description>
<AssemblyName>PowerToys.Settings.UI.Lib</AssemblyName>
</PropertyGroup>
@@ -24,6 +23,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" />
<PackageReference Include="System.IO.Abstractions" />
</ItemGroup>

View File

@@ -96,7 +96,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.Utilities
return Directory.GetParent(settingsPath).FullName;
}
private static readonly interop.LayoutMapManaged LayoutMap = new interop.LayoutMapManaged();
private static readonly global::PowerToys.Interop.LayoutMapManaged LayoutMap = new global::PowerToys.Interop.LayoutMapManaged();
public static string GetKeyName(uint key)
{
@@ -110,7 +110,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.Utilities
public static string GetProductVersion()
{
return interop.CommonManaged.GetProductVersion();
return global::PowerToys.Interop.CommonManaged.GetProductVersion();
}
public static int CompareVersions(string version1, string version2)
@@ -148,6 +148,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library.Utilities
}
}
public const uint VirtualKeyWindows = interop.Constants.VK_WIN_BOTH;
public static readonly uint VirtualKeyWindows = global::PowerToys.Interop.Constants.VK_WIN_BOTH;
}
}