[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

@@ -18,12 +18,13 @@ using global::PowerToys.GPOWrapper;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Microsoft.Win32;
using Windows.Security.Credentials;
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"];
@@ -387,7 +388,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
AdvancedPasteSettings.ModuleName,
JsonSerializer.Serialize(_advancedPasteSettings)));
JsonSerializer.Serialize(_advancedPasteSettings, SourceGenerationContextContext.Default.AdvancedPasteSettings)));
}
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.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class AlwaysOnTopViewModel : Observable
public partial class AlwaysOnTopViewModel : Observable
{
private ISettingsUtils SettingsUtils { get; set; }
@@ -131,7 +132,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
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
{
public class AwakeViewModel : Observable
public partial class AwakeViewModel : Observable
{
public AwakeViewModel()
{

View File

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

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

View File

@@ -7,7 +7,7 @@ using System.Windows.Input;
namespace Microsoft.PowerToys.Settings.UI.ViewModels.Commands
{
public class ButtonClickCommand : ICommand
public partial class ButtonClickCommand : ICommand
{
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.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class CropAndLockViewModel : Observable
public partial class CropAndLockViewModel : Observable
{
private ISettingsUtils SettingsUtils { get; set; }
@@ -122,7 +123,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
CropAndLockSettings.ModuleName,
JsonSerializer.Serialize(Settings)));
JsonSerializer.Serialize(Settings, SourceGenerationContextContext.Default.CropAndLockSettings)));
}
}
}
@@ -153,7 +154,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
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
{
public class DashboardListItem : INotifyPropertyChanged
public partial class DashboardListItem : INotifyPropertyChanged
{
private bool _visible;
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 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; }
@@ -31,12 +31,12 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public RoutedEventHandler ButtonClickHandler { get; set; }
}
public class DashboardModuleShortcutItem : DashboardModuleItem
public partial class DashboardModuleShortcutItem : DashboardModuleItem
{
public List<object> Shortcut { get; set; }
}
public class DashboardModuleKBMItem : DashboardModuleItem
public partial class DashboardModuleKBMItem : DashboardModuleItem
{
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; }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -12,6 +12,7 @@ using System.IO.Abstractions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
using System.Threading.Tasks;
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.Utilities;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Microsoft.PowerToys.Telemetry;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class GeneralViewModel : Observable
public partial class GeneralViewModel : Observable
{
private GeneralSettings GeneralSettingsConfig { get; set; }
@@ -34,7 +36,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public ButtonClickCommand CheckForUpdatesEventHandler { get; set; }
public object ResourceLoader { get; set; }
public Windows.ApplicationModel.Resources.ResourceLoader ResourceLoader { get; set; }
private Action HideBackupAndRestoreMessageAreaAction { get; set; }
@@ -70,7 +72,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
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);
RestartElevatedButtonEventHandler = new ButtonClickCommand(RestartElevated);
@@ -1075,11 +1077,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (ResourceLoader != null)
{
var type = ResourceLoader.GetType();
MethodInfo methodInfo = type.GetMethod("GetString");
object classInstance = Activator.CreateInstance(type, null);
object[] parametersArray = new object[] { resource };
var result = (string)methodInfo.Invoke(ResourceLoader, parametersArray);
var result = ResourceLoader.GetString(resource);
if (string.IsNullOrEmpty(result))
{
return resource.ToUpperInvariant() + "!!!";
@@ -1129,7 +1127,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);
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);
}

View File

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

View File

@@ -23,7 +23,7 @@ using Microsoft.Win32;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class KeyboardManagerViewModel : Observable
public partial class KeyboardManagerViewModel : Observable
{
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.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class MeasureToolViewModel : Observable
public partial class MeasureToolViewModel : Observable
{
private ISettingsUtils SettingsUtils { get; set; }
@@ -213,7 +214,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
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.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Microsoft.UI;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml.Media;
@@ -29,7 +30,7 @@ using Windows.ApplicationModel.DataTransfer;
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
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 sealed class SyncHelper : IDisposable
private sealed partial class SyncHelper : IDisposable
{
public SyncHelper(NamedPipeClientStream stream)
{
@@ -1102,7 +1103,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private IndexedObservableCollection<DeviceViewModel> machineMatrixString;
public class DeviceViewModel : Observable
public partial class DeviceViewModel : Observable
{
public string Name { get; set; }
@@ -1204,7 +1205,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
MouseWithoutBordersSettings.ModuleName,
JsonSerializer.Serialize(Settings)));
JsonSerializer.Serialize(Settings, SourceGenerationContextContext.Default.MouseWithoutBordersSettings)));
}
public void NotifyUpdatedSettings()

View File

@@ -12,12 +12,12 @@ using System.Threading.Tasks;
using System.Windows;
using global::PowerToys.GPOWrapper;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Windows.ApplicationModel.VoiceCommands;
using Windows.System;
@@ -25,7 +25,7 @@ using static Microsoft.PowerToys.Settings.UI.Helpers.ShellGetFolder;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class NewPlusViewModel : Observable
public partial class NewPlusViewModel : Observable
{
private GeneralSettings GeneralSettingsConfig { get; set; }
@@ -189,7 +189,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
ModuleName,
JsonSerializer.Serialize(Settings)));
JsonSerializer.Serialize(Settings, SourceGenerationContextContext.Default.NewPlusSettings)));
}
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.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Settings.UI.Library;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class PeekViewModel : Observable
public partial class PeekViewModel : Observable
{
private bool _isEnabled;
@@ -224,7 +225,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
PeekSettings.ModuleName,
JsonSerializer.Serialize(_peekSettings)));
JsonSerializer.Serialize(_peekSettings, SourceGenerationContextContext.Default.PeekSettings)));
}
private void SavePreviewSettings()

View File

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

View File

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

View File

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

View File

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

View File

@@ -13,7 +13,7 @@ using Settings.UI.Library.Enumerations;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class PowerPreviewViewModel : Observable
public partial class PowerPreviewViewModel : Observable
{
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
{
public class PowerRenameViewModel : Observable
public partial class PowerRenameViewModel : Observable
{
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.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class RegistryPreviewViewModel : Observable
public partial class RegistryPreviewViewModel : Observable
{
private GeneralSettings GeneralSettingsConfig { get; set; }
@@ -121,7 +122,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
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
{
public class ShellViewModel : Observable
public partial class ShellViewModel : Observable
{
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
{
public class ShortcutGuideViewModel : Observable
public partial class ShortcutGuideViewModel : Observable
{
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.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class WorkspacesViewModel : Observable
public partial class WorkspacesViewModel : Observable
{
private ISettingsUtils SettingsUtils { get; set; }
@@ -131,7 +132,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
WorkspacesSettings.ModuleName,
JsonSerializer.Serialize(Settings)));
JsonSerializer.Serialize(Settings, SourceGenerationContextContext.Default.WorkspacesSettings)));
}
}
}