Skip to content

Settings AOT#47794

Draft
LegendaryBlair wants to merge 4 commits into
mainfrom
shawn/settingsAOT
Draft

Settings AOT#47794
LegendaryBlair wants to merge 4 commits into
mainfrom
shawn/settingsAOT

Conversation

@LegendaryBlair
Copy link
Copy Markdown
Contributor

This pull request introduces significant improvements to AOT (Ahead-Of-Time) compatibility, especially for the MouseWithoutBorders module and the Settings UI. The main changes include replacing StreamJsonRpc-based IPC with a new AOT-friendly named pipe protocol, updating type annotations for trimming safety, and ensuring shared models for cross-process communication. There are also updates to build scripts and project files to support these changes.

AOT Compatibility and IPC Overhaul:

  • Introduced a new AOT-compatible IPC server for MouseWithoutBorders, replacing StreamJsonRpc with a custom named pipe protocol. This includes the new MouseWithoutBordersIpcServer class, a corresponding handler interface, and a serializable MachineSocketState struct for communication. (src/modules/MouseWithoutBorders/App/Class/MouseWithoutBordersIpcServer.cs, src/modules/MouseWithoutBorders/App/Class/Program.cs) [1] [2] [3] [4]
  • Updated the SocketStatus enum to be public for serialization, ensuring it matches between the service and the Settings UI. (src/modules/MouseWithoutBorders/App/Class/SocketStuff.cs)
  • Added a shared model for SocketStatus and MachineSocketState in the Settings UI library for consistent IPC communication. (src/settings-ui/Settings.UI.Library/MouseWithoutBordersIpcModels.cs)

AOT/Trimming Safety Improvements:

  • Annotated generic and reflection-heavy APIs with [DynamicallyAccessedMembers] to ensure correct behavior under trimming/AOT. This includes updates to GenericProperty<T> and methods in ICmdLineRepresentable. (src/settings-ui/Settings.UI.Library/GenericProperty1.cs, src/settings-ui/Settings.UI.Library/Interfaces/ICmdLineRepresentable.cs`) [1] [2] [3] [4] [5]
  • Expanded the list of warnings suppressed for AOT compatibility in the shared props file. (src/Common.Dotnet.AotCompatibility.props)

Build and Project File Updates:

  • Added AOT compatibility imports and conditional AOT publish settings to Settings UI and QuickAccess UI project files. (src/settings-ui/Settings.UI.Library/Settings.UI.Library.csproj, src/settings-ui/QuickAccess.UI/PowerToys.QuickAccess.csproj) [1] [2]
  • Introduced a new PowerShell script to publish Settings UI dependencies with the correct runtime identifier for AOT scenarios. (publish-settings-dependencies.ps1)

Infrastructure and Solution Tweaks:

  • Updated the solution file to exclude Microsoft.CmdPal.Ext.Shell from Release|x64 builds, possibly for AOT build streamlining. (PowerToys.slnx)

Minor Internal Refactors:

  • Added missing using directives and minor namespace adjustments to support the above changes. (src/modules/MouseWithoutBorders/App/Core/Common.cs, src/modules/MouseWithoutBorders/App/Class/Program.cs, src/settings-ui/Settings.UI.Library/Interfaces/ICmdLineRepresentable.cs) [1] [2] [3]

var serverTaskCancellationSource = new CancellationTokenSource();
CancellationToken cancellationToken = serverTaskCancellationSource.Token;

// Use AOT-compatible IPC server if available, otherwise use StreamJsonRpc
<!-- Preserve all of Newtonsoft.Json -->
<assembly fullname="Newtonsoft.Json" preserve="all" />

<!-- Preserve all of Nerdbank.Streams -->
<assembly fullname="Newtonsoft.Json" preserve="all" />

<!-- Preserve all of Nerdbank.Streams -->
<assembly fullname="Nerdbank.Streams" preserve="all" />
<TieredCompilation>true</TieredCompilation>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
<PublishReadyToRun>true</PublishReadyToRun>
<ReadyToRunUseCrossgen2>true</ReadyToRunUseCrossgen2>
<TieredCompilation>true</TieredCompilation>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
<PublishReadyToRun>true</PublishReadyToRun>
<ReadyToRunUseCrossgen2>true</ReadyToRunUseCrossgen2>

<!-- Additional optimizations for Release builds -->
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<IlcOptimizationPreference>Speed</IlcOptimizationPreference>
</PropertyGroup>

<!-- For debugging purposes, uncomment this block to enable AOT builds -->
<PropertyGroup>
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
<PublishDir>$(PowerToysRoot)\$(Platform)\$(Configuration)\WinUI3Apps</PublishDir>
<RuntimeIdentifier>win-$(Platform)</RuntimeIdentifier>
<PublishDir>C:\Users\shuaiyuan\source\repos\PowerToys\x64\Release\WinUI3Apps\Publish</PublishDir>
@github-actions
Copy link
Copy Markdown

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, 👼 SARIF report, or 📝 job summary for details.

Unrecognized words (4)

Crossgen
Ilc
Nerdbank
shuaiyuan

These words are not needed and should be removed DEFAULTTONEAREST

To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the git@github.com:microsoft/PowerToys.git repository
on the shawn/settingsAOT branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/cfb6f7e75bbfc89c71eaa30366d0c166f1bd9c8c/apply.pl' |
perl - 'https://github.com/microsoft/PowerToys/actions/runs/25657438634/attempts/1' &&
git commit -m 'Update check-spelling metadata'

OR

To have the bot accept them for you, comment in the PR quoting the following line:
@check-spelling-bot apply updates.

Forbidden patterns 🙅 (1)

In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves.

These forbidden patterns matched content:

Should be ; otherwise or . Otherwise

https://study.com/learn/lesson/otherwise-in-a-sentence.html

, [Oo]therwise\b
Errors ❌ (1)

See the 📂 files view, the 📜action log, 👼 SARIF report, or 📝 job summary for details.

❌ Errors Count
❌ forbidden-pattern 1

See ❌ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants