CmdPal: Refactoring DI, Logging, and Extension Services#45437
Draft
michaeljolley wants to merge 15 commits intomainfrom
Draft
CmdPal: Refactoring DI, Logging, and Extension Services#45437michaeljolley wants to merge 15 commits intomainfrom
michaeljolley wants to merge 15 commits intomainfrom
Conversation
- Move project from Core/ subfolder to cmdpal/ root - Update namespace from Microsoft.CmdPal.Core.Common to Microsoft.CmdPal.Common - Update all project references and using statements - Update solution files (PowerToys.slnx, CommandPalette.slnf)
…wModels - Move all source files from Core.ViewModels to UI.ViewModels - Update namespace from Microsoft.CmdPal.Core.ViewModels to Microsoft.CmdPal.UI.ViewModels - Remove Core.ViewModels project from solution files - Update all using statements in dependent projects - Delete the Core folder which is now empty
- Extract persistence logic into PersistenceService - Add AppStateService to manage app state - Add SettingsService to manage settings - Add JsonSerializationContext for AOT-compatible JSON - Add EscapeKeyBehavior and MonitorBehavior enums
UI.ViewModels: - CommandSettingsViewModel: Add ILogger injection - CommandItemViewModel: Add ILogger with LoggerMessage methods - ContextMenuViewModel: Add ILogger injection - ExtensionObjectViewModel: Add Logger property with NullLogger default - ShellViewModel: Replace CoreLogger calls with LoggerMessage methods - UpdateCommandBarMessage: Remove logging from interface default method UI helpers/services: - WallpaperHelper: Add ILogger injection with LoggerMessage methods - LocalKeyboardListener: Add ILogger injection with LoggerMessage methods - ImageProvider: Add ILogger injection with LoggerMessage methods - ThemeService: Add ILogger injection with LoggerMessage methods Note: UI project migration is partial - XAML code-behind files still use static Logger
- Update all ViewModels to receive SettingsService via DI - Implement IDisposable pattern for proper event cleanup - Add App.Services property for DI access where needed - Restore GetProviderSettings/GetGlobalFallbacks to SettingsModel - Fix CommandProviderWrapper and TopLevelCommandManager logging - Update all Settings pages to use SettingsService - Add DefaultAppExtensionHost to replace CommandPaletteHost.Instance - Add parameterless constructors for XAML-instantiated types - Fix various ILogger injection issues throughout UI layer
|
|
||
| [LoggerMessage( | ||
| Level = LogLevel.Warning, | ||
| Message = "Unrecognized target for shell navigation: {paramter}")] |
Check failure
Code scanning / check-spelling
Unrecognized Spelling Error
| [LoggerMessage( | ||
| Level = LogLevel.Warning, | ||
| Message = "Unrecognized target for shell navigation: {paramter}")] | ||
| partial void Log_UnrecognizedShellNavigationTargetWarning(object paramter); |
Check failure
Code scanning / check-spelling
Unrecognized Spelling Error
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This is a freaking huge PR. In it we:
App.Current.Services). Rather, services and models are injected into their requesting classes & controls via their constructor.TopLevelCommandManagerand, from there, loading 3P extensions in a combination of the TLCM and theExtensionsService, we now register IExtensionServices and TLCM uses any that are provided to load extensions & commands. This includes a newBuiltInExtensionServiceandWinRTExtensionServiceto load built-ins and 3P extension respectively. In the future, we hope to extend this to support extensions written in other languages, alaJsonRPCExtensionService.PersistenceServiceto be the backer of all services that need to persist data (e.g.SettingsService,AppStateService,PersonalizationService). It provides consolidated and generic methods for saving and loading persisted objects in JSON..Core. All those viewmodels, etc. are now moved to either theCommon,UI, orUI.ViewModelsprojects.