[AOT] clean up AOT issue in Settings.UI (#36559)

* Rename source generation context file

* fix build issue

* fix path bug

---------

Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
This commit is contained in:
moooyo
2025-02-25 02:48:54 +08:00
committed by GitHub
parent 9f008a65d6
commit f81f65db3d
45 changed files with 203 additions and 98 deletions

View File

@@ -0,0 +1,48 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Microsoft.PowerToys.Settings.UI.Helpers
{
public sealed class ActionMessage
{
[JsonPropertyName("action")]
public SettingsAction Action { get; set; }
public static ActionMessage Create(string actionName)
{
return new ActionMessage
{
Action = new SettingsAction
{
PublishedDate = new SettingsGeneral
{
ActionName = actionName,
},
},
};
}
}
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Those are just a define for one simple struct")]
public sealed class SettingsAction
{
[JsonPropertyName("general")]
public SettingsGeneral PublishedDate { get; set; }
}
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Those are just a define for one simple struct")]
public sealed class SettingsGeneral
{
[JsonPropertyName("action_name")]
public string ActionName { get; set; }
}
}

View File

@@ -11,7 +11,7 @@ using System.Windows.Input;
namespace Microsoft.PowerToys.Settings.UI.Helpers namespace Microsoft.PowerToys.Settings.UI.Helpers
{ {
internal sealed class AsyncCommand : ICommand internal sealed partial class AsyncCommand : ICommand
{ {
private readonly Func<Task> _execute; private readonly Func<Task> _execute;
private readonly Func<bool> _canExecute; private readonly Func<bool> _canExecute;

View File

@@ -27,7 +27,7 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
} }
#pragma warning disable SA1402 // File may only contain a single type #pragma warning disable SA1402 // File may only contain a single type
public class IndexedObservableCollection<T> : ObservableCollection<IndexedItem<T>> public partial class IndexedObservableCollection<T> : ObservableCollection<IndexedItem<T>>
#pragma warning restore SA1402 // File may only contain a single type #pragma warning restore SA1402 // File may only contain a single type
{ {
public IndexedObservableCollection(IEnumerable<T> items) public IndexedObservableCollection(IEnumerable<T> items)

View File

@@ -18,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
internal static int Size internal static int Size
{ {
get { return Marshal.SizeOf(typeof(INPUT)); } get { return Marshal.SizeOf<INPUT>(); }
} }
} }

View File

@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Microsoft.PowerToys.Settings.UI.Helpers
{
// Contains information for a release. Used to deserialize release JSON info from GitHub.
public sealed class PowerToysReleaseInfo
{
[JsonPropertyName("published_at")]
public DateTimeOffset PublishedDate { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("tag_name")]
public string TagName { get; set; }
[JsonPropertyName("body")]
public string ReleaseNotes { get; set; }
}
}

View File

@@ -7,7 +7,7 @@ using System.Windows.Input;
namespace Microsoft.PowerToys.Settings.UI.Helpers namespace Microsoft.PowerToys.Settings.UI.Helpers
{ {
public class RelayCommand : ICommand public partial class RelayCommand : ICommand
{ {
private readonly Action _execute; private readonly Action _execute;
private readonly Func<bool> _canExecute; private readonly Func<bool> _canExecute;
@@ -33,7 +33,7 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "abstract T and abstract")] [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "abstract T and abstract")]
public class RelayCommand<T> : ICommand public partial class RelayCommand<T> : ICommand
{ {
private readonly Action<T> execute; private readonly Action<T> execute;

View File

@@ -6,7 +6,7 @@ using System;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text.Json; using System.Text.Json;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
namespace Microsoft.PowerToys.Settings.UI.Helpers namespace Microsoft.PowerToys.Settings.UI.Helpers
@@ -20,9 +20,9 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
try try
{ {
var json = File.ReadAllText(_placementPath); var json = File.ReadAllText(_placementPath);
var placement = JsonSerializer.Deserialize<WINDOWPLACEMENT>(json); var placement = JsonSerializer.Deserialize<WINDOWPLACEMENT>(json, SourceGenerationContextContext.Default.WINDOWPLACEMENT);
placement.Length = Marshal.SizeOf(typeof(WINDOWPLACEMENT)); placement.Length = Marshal.SizeOf<WINDOWPLACEMENT>();
placement.Flags = 0; placement.Flags = 0;
placement.ShowCmd = (placement.ShowCmd == NativeMethods.SW_SHOWMAXIMIZED) ? NativeMethods.SW_SHOWMAXIMIZED : NativeMethods.SW_SHOWNORMAL; placement.ShowCmd = (placement.ShowCmd == NativeMethods.SW_SHOWMAXIMIZED) ? NativeMethods.SW_SHOWMAXIMIZED : NativeMethods.SW_SHOWNORMAL;
return placement; return placement;
@@ -40,7 +40,7 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
_ = NativeMethods.GetWindowPlacement(handle, out var placement); _ = NativeMethods.GetWindowPlacement(handle, out var placement);
try try
{ {
var json = JsonSerializer.Serialize(placement); var json = JsonSerializer.Serialize(placement, SourceGenerationContextContext.Default.WINDOWPLACEMENT);
File.WriteAllText(_placementPath, json); File.WriteAllText(_placementPath, json);
} }
catch (Exception) catch (Exception)

View File

@@ -0,0 +1,35 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library;
namespace Microsoft.PowerToys.Settings.UI.SerializationContext;
[JsonSerializable(typeof(WINDOWPLACEMENT))]
[JsonSerializable(typeof(AdvancedPasteSettings))]
[JsonSerializable(typeof(Dictionary<string, List<string>>))]
[JsonSerializable(typeof(AlwaysOnTopSettings))]
[JsonSerializable(typeof(ColorPickerSettings))]
[JsonSerializable(typeof(CropAndLockSettings))]
[JsonSerializable(typeof(FileLocksmithSettings))]
[JsonSerializable(typeof(MeasureToolSettings))]
[JsonSerializable(typeof(MouseWithoutBordersSettings))]
[JsonSerializable(typeof(NewPlusSettings))]
[JsonSerializable(typeof(PeekSettings))]
[JsonSerializable(typeof(PowerLauncherSettings))]
[JsonSerializable(typeof(PowerOcrSettings))]
[JsonSerializable(typeof(RegistryPreviewSettings))]
[JsonSerializable(typeof(WorkspacesSettings))]
[JsonSerializable(typeof(IList<PowerToysReleaseInfo>))]
[JsonSerializable(typeof(ActionMessage))]
public sealed partial class SourceGenerationContextContext : JsonSerializerContext
{
}

View File

@@ -14,6 +14,7 @@ using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers; using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Telemetry.Events; using Microsoft.PowerToys.Settings.UI.Library.Telemetry.Events;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Microsoft.PowerToys.Settings.UI.Services; using Microsoft.PowerToys.Settings.UI.Services;
using Microsoft.PowerToys.Settings.UI.Views; using Microsoft.PowerToys.Settings.UI.Views;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
@@ -167,7 +168,7 @@ namespace Microsoft.PowerToys.Settings.UI
try try
{ {
var requestedSettings = JsonSerializer.Deserialize<Dictionary<string, List<string>>>(File.ReadAllText(ipcFileName)); var requestedSettings = JsonSerializer.Deserialize<Dictionary<string, List<string>>>(File.ReadAllText(ipcFileName), SourceGenerationContextContext.Default.DictionaryStringListString);
File.WriteAllText(ipcFileName, GetSettingCommandLineCommand.Execute(requestedSettings)); File.WriteAllText(ipcFileName, GetSettingCommandLineCommand.Execute(requestedSettings));
} }
catch (Exception ex) catch (Exception ex)

View File

@@ -20,6 +20,7 @@ using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers; using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.OOBE.Enums; using Microsoft.PowerToys.Settings.UI.OOBE.Enums;
using Microsoft.PowerToys.Settings.UI.OOBE.ViewModel; using Microsoft.PowerToys.Settings.UI.OOBE.ViewModel;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Microsoft.PowerToys.Settings.UI.Views; using Microsoft.PowerToys.Settings.UI.Views;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
@@ -29,22 +30,6 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{ {
public sealed partial class OobeWhatsNew : Page public sealed partial class OobeWhatsNew : Page
{ {
// Contains information for a release. Used to deserialize release JSON info from GitHub.
private sealed class PowerToysReleaseInfo
{
[JsonPropertyName("published_at")]
public DateTimeOffset PublishedDate { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("tag_name")]
public string TagName { get; set; }
[JsonPropertyName("body")]
public string ReleaseNotes { get; set; }
}
public OobePowerToysModule ViewModel { get; set; } public OobePowerToysModule ViewModel { get; set; }
public bool ShowDataDiagnosticsInfoBar => GetShowDataDiagnosticsInfoBar(); public bool ShowDataDiagnosticsInfoBar => GetShowDataDiagnosticsInfoBar();
@@ -111,7 +96,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
// https://docs.github.com/rest/overview/resources-in-the-rest-api#user-agent-required // https://docs.github.com/rest/overview/resources-in-the-rest-api#user-agent-required
getReleaseInfoClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "PowerToys"); getReleaseInfoClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "PowerToys");
releaseNotesJSON = await getReleaseInfoClient.GetStringAsync("https://api.github.com/repos/microsoft/PowerToys/releases"); releaseNotesJSON = await getReleaseInfoClient.GetStringAsync("https://api.github.com/repos/microsoft/PowerToys/releases");
IList<PowerToysReleaseInfo> releases = JsonSerializer.Deserialize<IList<PowerToysReleaseInfo>>(releaseNotesJSON); IList<PowerToysReleaseInfo> releases = JsonSerializer.Deserialize<IList<PowerToysReleaseInfo>>(releaseNotesJSON, SourceGenerationContextContext.Default.IListPowerToysReleaseInfo);
// Get the latest releases // Get the latest releases
var latestReleases = releases.OrderByDescending(release => release.PublishedDate).Take(5); var latestReleases = releases.OrderByDescending(release => release.PublishedDate).Take(5);

View File

@@ -18,12 +18,13 @@ using global::PowerToys.GPOWrapper;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Microsoft.Win32; using Microsoft.Win32;
using Windows.Security.Credentials; using Windows.Security.Credentials;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class AdvancedPasteViewModel : Observable, IDisposable public partial class AdvancedPasteViewModel : Observable, IDisposable
{ {
private static readonly HashSet<string> WarnHotkeys = ["Ctrl + V", "Ctrl + Shift + V"]; private static readonly HashSet<string> WarnHotkeys = ["Ctrl + V", "Ctrl + Shift + V"];
@@ -387,7 +388,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
AdvancedPasteSettings.ModuleName, AdvancedPasteSettings.ModuleName,
JsonSerializer.Serialize(_advancedPasteSettings))); JsonSerializer.Serialize(_advancedPasteSettings, SourceGenerationContextContext.Default.AdvancedPasteSettings)));
} }
public void RefreshEnabledState() public void RefreshEnabledState()

View File

@@ -12,10 +12,11 @@ using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.Library.Utilities;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class AlwaysOnTopViewModel : Observable public partial class AlwaysOnTopViewModel : Observable
{ {
private ISettingsUtils SettingsUtils { get; set; } private ISettingsUtils SettingsUtils { get; set; }
@@ -131,7 +132,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
AlwaysOnTopSettings.ModuleName, AlwaysOnTopSettings.ModuleName,
JsonSerializer.Serialize(Settings))); JsonSerializer.Serialize(Settings, SourceGenerationContextContext.Default.AlwaysOnTopSettings)));
} }
} }
} }

View File

@@ -11,7 +11,7 @@ using Microsoft.PowerToys.Settings.UI.Library.Helpers;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class AwakeViewModel : Observable public partial class AwakeViewModel : Observable
{ {
public AwakeViewModel() public AwakeViewModel()
{ {

View File

@@ -19,7 +19,7 @@ using Microsoft.PowerToys.Telemetry;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class CmdNotFoundViewModel : Observable public partial class CmdNotFoundViewModel : Observable
{ {
public ButtonClickCommand CheckRequirementsEventHandler => new ButtonClickCommand(CheckCommandNotFoundRequirements); public ButtonClickCommand CheckRequirementsEventHandler => new ButtonClickCommand(CheckCommandNotFoundRequirements);
@@ -39,10 +39,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
get get
{ {
string codeBase = Assembly.GetExecutingAssembly().Location; return Path.TrimEndingDirectorySeparator(AppContext.BaseDirectory);
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
} }
} }

View File

@@ -16,10 +16,11 @@ using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Enumerations; using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class ColorPickerViewModel : Observable, IDisposable public partial class ColorPickerViewModel : Observable, IDisposable
{ {
private bool disposedValue; private bool disposedValue;
@@ -362,7 +363,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
ColorPickerSettings.ModuleName, ColorPickerSettings.ModuleName,
JsonSerializer.Serialize(_colorPickerSettings))); JsonSerializer.Serialize(_colorPickerSettings, SourceGenerationContextContext.Default.ColorPickerSettings)));
} }
public void RefreshEnabledState() public void RefreshEnabledState()

View File

@@ -7,7 +7,7 @@ using System.Windows.Input;
namespace Microsoft.PowerToys.Settings.UI.ViewModels.Commands namespace Microsoft.PowerToys.Settings.UI.ViewModels.Commands
{ {
public class ButtonClickCommand : ICommand public partial class ButtonClickCommand : ICommand
{ {
private readonly Action _execute; private readonly Action _execute;

View File

@@ -12,10 +12,11 @@ using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.Library.Utilities;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class CropAndLockViewModel : Observable public partial class CropAndLockViewModel : Observable
{ {
private ISettingsUtils SettingsUtils { get; set; } private ISettingsUtils SettingsUtils { get; set; }
@@ -122,7 +123,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
CropAndLockSettings.ModuleName, CropAndLockSettings.ModuleName,
JsonSerializer.Serialize(Settings))); JsonSerializer.Serialize(Settings, SourceGenerationContextContext.Default.CropAndLockSettings)));
} }
} }
} }
@@ -153,7 +154,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
CropAndLockSettings.ModuleName, CropAndLockSettings.ModuleName,
JsonSerializer.Serialize(Settings))); JsonSerializer.Serialize(Settings, SourceGenerationContextContext.Default.CropAndLockSettings)));
} }
} }
} }

View File

@@ -13,7 +13,7 @@ using Windows.UI;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class DashboardListItem : INotifyPropertyChanged public partial class DashboardListItem : INotifyPropertyChanged
{ {
private bool _visible; private bool _visible;
private bool _isEnabled; private bool _isEnabled;

View File

@@ -14,11 +14,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
#pragma warning disable SA1402 // File may only contain a single type #pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name #pragma warning disable SA1649 // File name should match first type name
public class DashboardModuleTextItem : DashboardModuleItem public partial class DashboardModuleTextItem : DashboardModuleItem
{ {
} }
public class DashboardModuleButtonItem : DashboardModuleItem public partial class DashboardModuleButtonItem : DashboardModuleItem
{ {
public string ButtonTitle { get; set; } public string ButtonTitle { get; set; }
@@ -31,12 +31,12 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public RoutedEventHandler ButtonClickHandler { get; set; } public RoutedEventHandler ButtonClickHandler { get; set; }
} }
public class DashboardModuleShortcutItem : DashboardModuleItem public partial class DashboardModuleShortcutItem : DashboardModuleItem
{ {
public List<object> Shortcut { get; set; } public List<object> Shortcut { get; set; }
} }
public class DashboardModuleKBMItem : DashboardModuleItem public partial class DashboardModuleKBMItem : DashboardModuleItem
{ {
private List<KeysDataModel> _remapKeys = new List<KeysDataModel>(); private List<KeysDataModel> _remapKeys = new List<KeysDataModel>();
@@ -55,7 +55,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
} }
} }
public class DashboardModuleItem : INotifyPropertyChanged public partial class DashboardModuleItem : INotifyPropertyChanged
{ {
public string Label { get; set; } public string Label { get; set; }

View File

@@ -22,7 +22,7 @@ using Microsoft.UI.Xaml.Controls;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class DashboardViewModel : Observable public partial class DashboardViewModel : Observable
{ {
private const string JsonFileType = ".json"; private const string JsonFileType = ".json";
private IFileSystemWatcher _watcher; private IFileSystemWatcher _watcher;
@@ -55,7 +55,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_allModules = new List<DashboardListItem>(); _allModules = new List<DashboardListItem>();
foreach (ModuleType moduleType in Enum.GetValues(typeof(ModuleType))) foreach (ModuleType moduleType in Enum.GetValues<ModuleType>())
{ {
AddDashboardListItem(moduleType); AddDashboardListItem(moduleType);
} }

View File

@@ -16,7 +16,7 @@ using Settings.UI.Library.Enumerations;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class EnvironmentVariablesViewModel : Observable public partial class EnvironmentVariablesViewModel : Observable
{ {
private bool _isElevated; private bool _isElevated;
private GpoRuleConfigured _enabledGpoRuleConfiguration; private GpoRuleConfigured _enabledGpoRuleConfiguration;

View File

@@ -13,7 +13,7 @@ using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class FancyZonesViewModel : Observable public partial class FancyZonesViewModel : Observable
{ {
private SettingsUtils SettingsUtils { get; set; } private SettingsUtils SettingsUtils { get; set; }

View File

@@ -10,10 +10,11 @@ using global::PowerToys.GPOWrapper;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class FileLocksmithViewModel : Observable public partial class FileLocksmithViewModel : Observable
{ {
private GeneralSettings GeneralSettingsConfig { get; set; } private GeneralSettings GeneralSettingsConfig { get; set; }
@@ -134,7 +135,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
FileLocksmithSettings.ModuleName, FileLocksmithSettings.ModuleName,
JsonSerializer.Serialize(Settings))); JsonSerializer.Serialize(Settings, SourceGenerationContextContext.Default.FileLocksmithSettings)));
} }
private Func<string, int> SendConfigMSG { get; } private Func<string, int> SendConfigMSG { get; }

View File

@@ -15,7 +15,7 @@ using Microsoft.Windows.ApplicationModel.Resources;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class AllAppsViewModel : Observable public partial class AllAppsViewModel : Observable
{ {
public ObservableCollection<FlyoutMenuItem> FlyoutMenuItems { get; set; } public ObservableCollection<FlyoutMenuItem> FlyoutMenuItems { get; set; }
@@ -34,7 +34,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
resourceLoader = Helpers.ResourceLoaderInstance.ResourceLoader; resourceLoader = Helpers.ResourceLoaderInstance.ResourceLoader;
FlyoutMenuItems = new ObservableCollection<FlyoutMenuItem>(); FlyoutMenuItems = new ObservableCollection<FlyoutMenuItem>();
foreach (ModuleType moduleType in Enum.GetValues(typeof(ModuleType))) foreach (ModuleType moduleType in Enum.GetValues<ModuleType>())
{ {
AddFlyoutMenuItem(moduleType); AddFlyoutMenuItem(moduleType);
} }

View File

@@ -10,7 +10,7 @@ using ManagedCommon;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class FlyoutMenuItem : INotifyPropertyChanged public partial class FlyoutMenuItem : INotifyPropertyChanged
{ {
private bool _visible; private bool _visible;
private bool _isEnabled; private bool _isEnabled;

View File

@@ -7,7 +7,7 @@ using System.Timers;
namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout namespace Microsoft.PowerToys.Settings.UI.ViewModels.Flyout
{ {
public class FlyoutViewModel : IDisposable public partial class FlyoutViewModel : IDisposable
{ {
private Timer _hideTimer; private Timer _hideTimer;
private bool _disposed; private bool _disposed;

View File

@@ -15,7 +15,7 @@ using Microsoft.Windows.ApplicationModel.Resources;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class LauncherViewModel : Observable public partial class LauncherViewModel : Observable
{ {
public bool IsUpdateAvailable { get; set; } public bool IsUpdateAvailable { get; set; }

View File

@@ -12,6 +12,7 @@ using System.IO.Abstractions;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
using System.Threading.Tasks; using System.Threading.Tasks;
using global::PowerToys.GPOWrapper; using global::PowerToys.GPOWrapper;
@@ -22,11 +23,12 @@ using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.Library.Utilities;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands; using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Microsoft.PowerToys.Telemetry; using Microsoft.PowerToys.Telemetry;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class GeneralViewModel : Observable public partial class GeneralViewModel : Observable
{ {
private GeneralSettings GeneralSettingsConfig { get; set; } private GeneralSettings GeneralSettingsConfig { get; set; }
@@ -34,7 +36,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public ButtonClickCommand CheckForUpdatesEventHandler { get; set; } public ButtonClickCommand CheckForUpdatesEventHandler { get; set; }
public object ResourceLoader { get; set; } public Windows.ApplicationModel.Resources.ResourceLoader ResourceLoader { get; set; }
private Action HideBackupAndRestoreMessageAreaAction { get; set; } private Action HideBackupAndRestoreMessageAreaAction { get; set; }
@@ -70,7 +72,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private SettingsBackupAndRestoreUtils settingsBackupAndRestoreUtils = SettingsBackupAndRestoreUtils.Instance; private SettingsBackupAndRestoreUtils settingsBackupAndRestoreUtils = SettingsBackupAndRestoreUtils.Instance;
public GeneralViewModel(ISettingsRepository<GeneralSettings> settingsRepository, string runAsAdminText, string runAsUserText, bool isElevated, bool isAdmin, Func<string, int> ipcMSGCallBackFunc, Func<string, int> ipcMSGRestartAsAdminMSGCallBackFunc, Func<string, int> ipcMSGCheckForUpdatesCallBackFunc, string configFileSubfolder = "", Action dispatcherAction = null, Action hideBackupAndRestoreMessageAreaAction = null, Action<int> doBackupAndRestoreDryRun = null, Func<Task<string>> pickSingleFolderDialog = null, object resourceLoader = null) public GeneralViewModel(ISettingsRepository<GeneralSettings> settingsRepository, string runAsAdminText, string runAsUserText, bool isElevated, bool isAdmin, Func<string, int> ipcMSGCallBackFunc, Func<string, int> ipcMSGRestartAsAdminMSGCallBackFunc, Func<string, int> ipcMSGCheckForUpdatesCallBackFunc, string configFileSubfolder = "", Action dispatcherAction = null, Action hideBackupAndRestoreMessageAreaAction = null, Action<int> doBackupAndRestoreDryRun = null, Func<Task<string>> pickSingleFolderDialog = null, Windows.ApplicationModel.Resources.ResourceLoader resourceLoader = null)
{ {
CheckForUpdatesEventHandler = new ButtonClickCommand(CheckForUpdatesClick); CheckForUpdatesEventHandler = new ButtonClickCommand(CheckForUpdatesClick);
RestartElevatedButtonEventHandler = new ButtonClickCommand(RestartElevated); RestartElevatedButtonEventHandler = new ButtonClickCommand(RestartElevated);
@@ -1075,11 +1077,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
if (ResourceLoader != null) if (ResourceLoader != null)
{ {
var type = ResourceLoader.GetType(); var result = ResourceLoader.GetString(resource);
MethodInfo methodInfo = type.GetMethod("GetString");
object classInstance = Activator.CreateInstance(type, null);
object[] parametersArray = new object[] { resource };
var result = (string)methodInfo.Invoke(ResourceLoader, parametersArray);
if (string.IsNullOrEmpty(result)) if (string.IsNullOrEmpty(result))
{ {
return resource.ToUpperInvariant() + "!!!"; return resource.ToUpperInvariant() + "!!!";
@@ -1129,7 +1127,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings); GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);
var dataToSend = customaction.ToString(); var dataToSend = customaction.ToString();
dataToSend = JsonSerializer.Serialize(new { action = new { general = new { action_name = "restart_maintain_elevation" } } }); dataToSend = JsonSerializer.Serialize(ActionMessage.Create("restart_maintain_elevation"), SourceGenerationContextContext.Default.ActionMessage);
SendRestartAsAdminConfigMSG(dataToSend); SendRestartAsAdminConfigMSG(dataToSend);
} }

View File

@@ -16,7 +16,7 @@ using Settings.UI.Library.Enumerations;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class HostsViewModel : Observable public partial class HostsViewModel : Observable
{ {
private bool _isElevated; private bool _isElevated;
private GpoRuleConfigured _enabledGpoRuleConfiguration; private GpoRuleConfigured _enabledGpoRuleConfiguration;

View File

@@ -23,7 +23,7 @@ using Microsoft.Win32;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class KeyboardManagerViewModel : Observable public partial class KeyboardManagerViewModel : Observable
{ {
private GeneralSettings GeneralSettingsConfig { get; set; } private GeneralSettings GeneralSettingsConfig { get; set; }

View File

@@ -11,10 +11,11 @@ using global::PowerToys.GPOWrapper;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class MeasureToolViewModel : Observable public partial class MeasureToolViewModel : Observable
{ {
private ISettingsUtils SettingsUtils { get; set; } private ISettingsUtils SettingsUtils { get; set; }
@@ -213,7 +214,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
MeasureToolSettings.ModuleName, MeasureToolSettings.ModuleName,
JsonSerializer.Serialize(Settings))); JsonSerializer.Serialize(Settings, SourceGenerationContextContext.Default.MeasureToolSettings)));
} }
} }
} }

View File

@@ -21,6 +21,7 @@ using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands; using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Microsoft.UI; using Microsoft.UI;
using Microsoft.UI.Dispatching; using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Media;
@@ -29,7 +30,7 @@ using Windows.ApplicationModel.DataTransfer;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class MouseWithoutBordersViewModel : Observable, IDisposable public partial class MouseWithoutBordersViewModel : Observable, IDisposable
{ {
// These should be in the same order as the ComboBoxItems in MouseWithoutBordersPage.xaml switch machine shortcut options // These should be in the same order as the ComboBoxItems in MouseWithoutBordersPage.xaml switch machine shortcut options
private readonly int[] _switchBetweenMachineShortcutOptions = private readonly int[] _switchBetweenMachineShortcutOptions =
@@ -277,7 +278,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private static VisualStudio.Threading.AsyncSemaphore _ipcSemaphore = new VisualStudio.Threading.AsyncSemaphore(1); private static VisualStudio.Threading.AsyncSemaphore _ipcSemaphore = new VisualStudio.Threading.AsyncSemaphore(1);
private sealed class SyncHelper : IDisposable private sealed partial class SyncHelper : IDisposable
{ {
public SyncHelper(NamedPipeClientStream stream) public SyncHelper(NamedPipeClientStream stream)
{ {
@@ -1102,7 +1103,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private IndexedObservableCollection<DeviceViewModel> machineMatrixString; private IndexedObservableCollection<DeviceViewModel> machineMatrixString;
public class DeviceViewModel : Observable public partial class DeviceViewModel : Observable
{ {
public string Name { get; set; } public string Name { get; set; }
@@ -1204,7 +1205,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
MouseWithoutBordersSettings.ModuleName, MouseWithoutBordersSettings.ModuleName,
JsonSerializer.Serialize(Settings))); JsonSerializer.Serialize(Settings, SourceGenerationContextContext.Default.MouseWithoutBordersSettings)));
} }
public void NotifyUpdatedSettings() public void NotifyUpdatedSettings()

View File

@@ -12,12 +12,12 @@ using System.Threading.Tasks;
using System.Windows; using System.Windows;
using global::PowerToys.GPOWrapper; using global::PowerToys.GPOWrapper;
using ManagedCommon; using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.Library.Utilities;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands; using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Windows.ApplicationModel.VoiceCommands; using Windows.ApplicationModel.VoiceCommands;
using Windows.System; using Windows.System;
@@ -25,7 +25,7 @@ using static Microsoft.PowerToys.Settings.UI.Helpers.ShellGetFolder;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class NewPlusViewModel : Observable public partial class NewPlusViewModel : Observable
{ {
private GeneralSettings GeneralSettingsConfig { get; set; } private GeneralSettings GeneralSettingsConfig { get; set; }
@@ -189,7 +189,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
ModuleName, ModuleName,
JsonSerializer.Serialize(Settings))); JsonSerializer.Serialize(Settings, SourceGenerationContextContext.Default.NewPlusSettings)));
} }
private Func<string, int> SendConfigMSG { get; } private Func<string, int> SendConfigMSG { get; }

View File

@@ -10,11 +10,12 @@ using global::PowerToys.GPOWrapper;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Settings.UI.Library; using Settings.UI.Library;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class PeekViewModel : Observable public partial class PeekViewModel : Observable
{ {
private bool _isEnabled; private bool _isEnabled;
@@ -224,7 +225,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
PeekSettings.ModuleName, PeekSettings.ModuleName,
JsonSerializer.Serialize(_peekSettings))); JsonSerializer.Serialize(_peekSettings, SourceGenerationContextContext.Default.PeekSettings)));
} }
private void SavePreviewSettings() private void SavePreviewSettings()

View File

@@ -11,7 +11,7 @@ using Microsoft.PowerToys.Settings.UI.Library;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class PluginAdditionalOptionViewModel : INotifyPropertyChanged public partial class PluginAdditionalOptionViewModel : INotifyPropertyChanged
{ {
private PluginAdditionalOption _additionalOption; private PluginAdditionalOption _additionalOption;

View File

@@ -15,7 +15,7 @@ using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class PowerAccentViewModel : Observable public partial class PowerAccentViewModel : Observable
{ {
private GeneralSettings GeneralSettingsConfig { get; set; } private GeneralSettings GeneralSettingsConfig { get; set; }

View File

@@ -14,7 +14,7 @@ using Microsoft.PowerToys.Settings.UI.Library;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class PowerLauncherPluginViewModel : INotifyPropertyChanged public partial class PowerLauncherPluginViewModel : INotifyPropertyChanged
{ {
private readonly PowerLauncherPluginSettings settings; private readonly PowerLauncherPluginSettings settings;
private readonly Func<bool> isDark; private readonly Func<bool> isDark;

View File

@@ -17,10 +17,11 @@ using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands; using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class PowerLauncherViewModel : Observable public partial class PowerLauncherViewModel : Observable
{ {
private int _themeIndex; private int _themeIndex;
private int _monitorPositionIndex; private int _monitorPositionIndex;
@@ -74,7 +75,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
PowerLauncherSettings.ModuleName, PowerLauncherSettings.ModuleName,
JsonSerializer.Serialize(s))); JsonSerializer.Serialize(s, SourceGenerationContextContext.Default.PowerLauncherSettings)));
}; };
switch (settings.Properties.Theme) switch (settings.Properties.Theme)
@@ -103,7 +104,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
break; break;
} }
SearchPluginsCommand = new RelayCommand(SearchPlugins); SearchPluginsCommand = new Library.ViewModels.Commands.RelayCommand(SearchPlugins);
} }
private void InitializeEnabledValue() private void InitializeEnabledValue()

View File

@@ -14,12 +14,13 @@ using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Windows.Globalization; using Windows.Globalization;
using Windows.Media.Ocr; using Windows.Media.Ocr;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class PowerOcrViewModel : Observable, IDisposable public partial class PowerOcrViewModel : Observable, IDisposable
{ {
private bool disposedValue; private bool disposedValue;
@@ -236,7 +237,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
PowerOcrSettings.ModuleName, PowerOcrSettings.ModuleName,
JsonSerializer.Serialize(_powerOcrSettings))); JsonSerializer.Serialize(_powerOcrSettings, SourceGenerationContextContext.Default.PowerOcrSettings)));
} }
public void RefreshEnabledState() public void RefreshEnabledState()

View File

@@ -13,7 +13,7 @@ using Settings.UI.Library.Enumerations;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class PowerPreviewViewModel : Observable public partial class PowerPreviewViewModel : Observable
{ {
private const string ModuleName = PowerPreviewSettings.ModuleName; private const string ModuleName = PowerPreviewSettings.ModuleName;

View File

@@ -14,7 +14,7 @@ using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class PowerRenameViewModel : Observable public partial class PowerRenameViewModel : Observable
{ {
private GeneralSettings GeneralSettingsConfig { get; set; } private GeneralSettings GeneralSettingsConfig { get; set; }

View File

@@ -11,10 +11,11 @@ using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands; using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class RegistryPreviewViewModel : Observable public partial class RegistryPreviewViewModel : Observable
{ {
private GeneralSettings GeneralSettingsConfig { get; set; } private GeneralSettings GeneralSettingsConfig { get; set; }
@@ -121,7 +122,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
RegistryPreviewSettings.ModuleName, RegistryPreviewSettings.ModuleName,
JsonSerializer.Serialize(_settings))); JsonSerializer.Serialize(_settings, SourceGenerationContextContext.Default.RegistryPreviewSettings)));
} }
} }
} }

View File

@@ -19,7 +19,7 @@ using Windows.System;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class ShellViewModel : Observable public partial class ShellViewModel : Observable
{ {
private readonly KeyboardAccelerator altLeftKeyboardAccelerator = BuildKeyboardAccelerator(VirtualKey.Left, VirtualKeyModifiers.Menu); private readonly KeyboardAccelerator altLeftKeyboardAccelerator = BuildKeyboardAccelerator(VirtualKey.Left, VirtualKeyModifiers.Menu);

View File

@@ -12,7 +12,7 @@ using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class ShortcutGuideViewModel : Observable public partial class ShortcutGuideViewModel : Observable
{ {
private ISettingsUtils SettingsUtils { get; set; } private ISettingsUtils SettingsUtils { get; set; }

View File

@@ -12,10 +12,11 @@ using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands; using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
namespace Microsoft.PowerToys.Settings.UI.ViewModels namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
public class WorkspacesViewModel : Observable public partial class WorkspacesViewModel : Observable
{ {
private ISettingsUtils SettingsUtils { get; set; } private ISettingsUtils SettingsUtils { get; set; }
@@ -131,7 +132,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
WorkspacesSettings.ModuleName, WorkspacesSettings.ModuleName,
JsonSerializer.Serialize(Settings))); JsonSerializer.Serialize(Settings, SourceGenerationContextContext.Default.WorkspacesSettings)));
} }
} }
} }