Skip to content

Conversation

moooyo
Copy link
Contributor

@moooyo moooyo commented Oct 20, 2025

Summary of the Pull Request

Key Changes:

  1. Settings.UI.Library:

    • Added SettingsSerializationContext.cs with comprehensive JsonSerializable attributes for all settings types
    • Updated BasePTModuleSettings.ToJsonString() to use AOT-compatible serialization
    • Updated SettingsUtils.GetFile() to use AOT-compatible deserialization
    • Modified all ToString() methods in Properties classes to use SettingsSerializationContext
    • Converted struct fields to properties in SunTimes and MouseWithoutBordersProperties for serialization compatibility
  2. Settings.UI:

    • Fixed namespace alias in SourceGenerationContextContext.cs to avoid conflicts
  3. Documentation:

    • Added detailed XML documentation explaining AOT requirements and registration steps
    • Included clear error messages for unregistered types

PR Checklist

  • Closes: #xxx
  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

This commit refactors the PowerToys Settings UI Library and Settings UI to be compatible with Native AOT compilation by implementing source-generated JSON serialization.

Key Changes:

1. Settings.UI.Library:
   - Added SettingsSerializationContext.cs with comprehensive JsonSerializable attributes for all settings types
   - Updated BasePTModuleSettings.ToJsonString() to use AOT-compatible serialization
   - Updated SettingsUtils.GetFile<T>() to use AOT-compatible deserialization
   - Modified all ToString() methods in Properties classes to use SettingsSerializationContext
   - Converted struct fields to properties in SunTimes and MouseWithoutBordersProperties for serialization compatibility

2. Settings.UI:
   - Fixed namespace alias in SourceGenerationContextContext.cs to avoid conflicts

3. Documentation:
   - Added detailed XML documentation explaining AOT requirements and registration steps
   - Included clear error messages for unregistered types

These changes ensure Settings can be compiled with Native AOT while maintaining backward compatibility with the existing codebase.
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.

1 participant