From 997af8e1c7ed4c89ef9d34f84fd66684649dc6b2 Mon Sep 17 00:00:00 2001 From: vanzue Date: Fri, 9 May 2025 14:07:12 +0800 Subject: [PATCH 1/4] Add log to trace error for apps. --- .../Microsoft.CmdPal.Ext.Apps/AppCommand.cs | 4 +- .../Microsoft.CmdPal.Ext.Apps/AppListItem.cs | 6 ++- .../Commands/OpenInConsoleCommand.cs | 5 ++- .../Programs/PackageWrapper.cs | 2 + .../Microsoft.CmdPal.Ext.Apps/Programs/UWP.cs | 8 +++- .../Programs/UWPApplication.cs | 4 +- .../Programs/Win32Program.cs | 40 ++++++++++++++----- .../Storage/ListRepository`1.cs | 4 +- .../Storage/PackageRepository.cs | 5 ++- .../Storage/Win32ProgramFileSystemWatchers.cs | 4 +- .../Storage/Win32ProgramRepository.cs | 7 +++- .../Utils/ShellLinkHelper.cs | 9 +++-- 12 files changed, 69 insertions(+), 29 deletions(-) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs index 682c79bdb8..6cb416f271 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.Threading.Tasks; +using ManagedCommon; using Microsoft.CmdPal.Ext.Apps.Programs; using Microsoft.CmdPal.Ext.Apps.Properties; using Microsoft.CommandPalette.Extensions.Toolkit; @@ -33,8 +34,9 @@ internal sealed partial class AppCommand : InvokableCommand { appManager.ActivateApplication(aumid, /*queryArguments*/ string.Empty, noFlags, out var unusedPid); } - catch (System.Exception) + catch (System.Exception ex) { + Logger.LogError(ex.Message); } }).ConfigureAwait(false); } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppListItem.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppListItem.cs index 57c9175d4d..d67f9beed8 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppListItem.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppListItem.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using ManagedCommon; using Microsoft.CommandPalette.Extensions; using Microsoft.CommandPalette.Extensions.Toolkit; using Windows.Storage.Streams; @@ -73,10 +74,11 @@ internal sealed partial class AppListItem : ListItem heroImage = IconInfo.FromStream(stream); } } - catch (Exception) + catch (Exception ex) { + Logger.LogError(ex.Message); + // do nothing if we fail to load an icon. - // Logging it would be too NOISY, there's really no need. } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenInConsoleCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenInConsoleCommand.cs index de68cafeb8..41e934759a 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenInConsoleCommand.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenInConsoleCommand.cs @@ -5,6 +5,7 @@ using System; using System.Diagnostics; using System.Threading.Tasks; +using ManagedCommon; using Microsoft.CmdPal.Ext.Apps.Properties; using Microsoft.CommandPalette.Extensions.Toolkit; @@ -38,9 +39,9 @@ internal sealed partial class OpenInConsoleCommand : InvokableCommand Process.Start(processStartInfo); } - catch (Exception) + catch (Exception ex) { - // Log.Exception($"Failed to open {Name} in console, {e.Message}", e, GetType()); + Logger.LogError(ex.Message); } }); } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/PackageWrapper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/PackageWrapper.cs index 2de128c05c..00f33d1efd 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/PackageWrapper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/PackageWrapper.cs @@ -4,6 +4,7 @@ using System; using System.IO; +using ManagedCommon; using Windows.Foundation.Metadata; using Package = Windows.ApplicationModel.Package; @@ -51,6 +52,7 @@ public class PackageWrapper : IPackage } catch (Exception e) when (e is ArgumentException || e is FileNotFoundException || e is DirectoryNotFoundException) { + Logger.LogError(e.Message); return new PackageWrapper( package.Id.Name, package.Id.FullName, diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWP.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWP.cs index beba2b185a..e115911001 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWP.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWP.cs @@ -7,7 +7,9 @@ using System.Collections.Generic; using System.IO.Abstractions; using System.Linq; using System.Xml.Linq; +using ManagedCommon; using Microsoft.CmdPal.Ext.Apps.Utils; +using Microsoft.CommandPalette.Extensions.Toolkit; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.System.Com; @@ -131,8 +133,9 @@ public partial class UWP u = new UWP(p); u.InitializeAppInfo(p.InstalledLocation); } - catch (Exception ) + catch (Exception ex) { + Logger.LogError(ex.Message); return Array.Empty(); } @@ -161,8 +164,9 @@ public partial class UWP var path = p.InstalledLocation; return !f && !string.IsNullOrEmpty(path); } - catch (Exception ) + catch (Exception ex) { + Logger.LogError(ex.Message); return false; } }); diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs index 7a35400a7a..b549781b56 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs @@ -8,6 +8,7 @@ using System.IO.Abstractions; using System.Linq; using System.Text; using System.Xml; +using ManagedCommon; using Microsoft.CmdPal.Ext.Apps.Commands; using Microsoft.CmdPal.Ext.Apps.Properties; using Microsoft.CmdPal.Ext.Apps.Utils; @@ -154,8 +155,9 @@ public class UWPApplication : IProgram return true; } } - catch (Exception) + catch (Exception ex) { + Logger.LogError(ex.Message); } } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/Win32Program.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/Win32Program.cs index 48dfaa2f7e..11c9be6be5 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/Win32Program.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/Win32Program.cs @@ -15,6 +15,7 @@ using System.Security; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Input; +using ManagedCommon; using Microsoft.CmdPal.Ext.Apps.Commands; using Microsoft.CmdPal.Ext.Apps.Properties; using Microsoft.CmdPal.Ext.Apps.Utils; @@ -239,10 +240,12 @@ public class Win32Program : IProgram } catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException) { + Logger.LogError(e.Message); return InvalidProgram; } - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); return InvalidProgram; } } @@ -317,11 +320,13 @@ public class Win32Program : IProgram } catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException) { + Logger.LogError(e.Message); return InvalidProgram; } } - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); return InvalidProgram; } } @@ -374,15 +379,17 @@ public class Win32Program : IProgram return program; } - catch (System.IO.FileLoadException) + catch (System.IO.FileLoadException e) { + Logger.LogError(e.Message); return InvalidProgram; } // Only do a catch all in production. This is so make developer aware of any unhandled exception and add the exception handling in. // Error caused likely due to trying to get the description of the program - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); return InvalidProgram; } } @@ -402,14 +409,17 @@ public class Win32Program : IProgram } catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException) { + Logger.LogError(e.Message); return InvalidProgram; } - catch (FileNotFoundException) + catch (FileNotFoundException e) { + Logger.LogError(e.Message); return InvalidProgram; } - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); return InvalidProgram; } } @@ -515,16 +525,19 @@ public class Win32Program : IProgram { files.AddRange(Directory.EnumerateFiles(currentDirectory, $"*.{suffix}", SearchOption.TopDirectoryOnly)); } - catch (DirectoryNotFoundException) + catch (DirectoryNotFoundException e) { + Logger.LogError(e.Message); } } } catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException) { + Logger.LogError(e.Message); } - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); } try @@ -548,9 +561,11 @@ public class Win32Program : IProgram } catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException) { + Logger.LogError(e.Message); } - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); } } while (folderQueue.Count > 0); @@ -682,6 +697,7 @@ public class Win32Program : IProgram } catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException) { + Logger.LogError(e.Message); return string.Empty; } } @@ -769,8 +785,9 @@ public class Win32Program : IProgram icoPath = ExpandEnvironmentVariables(redirectionPath); return true; } - catch (IOException) + catch (IOException e) { + Logger.LogError(e.Message); } icoPath = null; @@ -839,8 +856,9 @@ public class Win32Program : IProgram return DeduplicatePrograms(programs.Concat(runCommandPrograms).Where(program => program?.Valid == true)); } - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); return Array.Empty(); } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/ListRepository`1.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/ListRepository`1.cs index aea8590c58..81d98b0b76 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/ListRepository`1.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/ListRepository`1.cs @@ -7,6 +7,7 @@ using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using ManagedCommon; namespace Microsoft.CmdPal.Ext.Apps.Storage; @@ -37,8 +38,9 @@ public class ListRepository : IRepository, IEnumerable _items = new ConcurrentDictionary(list.ToDictionary(i => i.GetHashCode())); #pragma warning restore CS8602 // Dereference of a possibly null reference. } - catch (ArgumentException) + catch (ArgumentException ex) { + Logger.LogError(ex.Message); } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/PackageRepository.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/PackageRepository.cs index 1f7a747d57..566817ea5d 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/PackageRepository.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/PackageRepository.cs @@ -4,8 +4,8 @@ using System; using System.Linq; +using ManagedCommon; using Microsoft.CmdPal.Ext.Apps.Programs; -using Microsoft.CmdPal.Ext.Apps.Storage; using Microsoft.CmdPal.Ext.Apps.Utils; using Windows.ApplicationModel; @@ -93,8 +93,9 @@ internal sealed partial class PackageRepository : ListRepository // InitializeAppInfo will throw if there is no AppxManifest.xml for the package. // Note there are sometimes multiple packages per product and this doesn't necessarily mean that we haven't found the app. // eg. "Could not find file 'C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminalPreview_2020.616.45.0_neutral_~_8wekyb3d8bbwe\\AppxManifest.xml'." - catch (System.IO.FileNotFoundException) + catch (System.IO.FileNotFoundException ex) { + Logger.LogError(ex.Message); } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramFileSystemWatchers.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramFileSystemWatchers.cs index 6847e619e1..3e992cc807 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramFileSystemWatchers.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramFileSystemWatchers.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using ManagedCommon; namespace Microsoft.CmdPal.Ext.Apps.Storage; @@ -47,8 +48,9 @@ internal sealed partial class Win32ProgramFileSystemWatchers : IDisposable { Directory.GetFiles(path); } - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); invalidPaths.Add(path); } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramRepository.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramRepository.cs index 5a0eb09451..9592599b17 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramRepository.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramRepository.cs @@ -9,6 +9,7 @@ using System.Collections.ObjectModel; using System.IO; using System.IO.Abstractions; using System.Threading.Tasks; +using ManagedCommon; using Microsoft.CmdPal.Ext.Apps.Programs; using Win32Program = Microsoft.CmdPal.Ext.Apps.Programs.Win32Program; @@ -132,8 +133,9 @@ internal sealed partial class Win32ProgramRepository : ListRepository Date: Fri, 9 May 2025 14:10:54 +0800 Subject: [PATCH 2/4] Add bookmark log --- .../BookmarkPlaceholderForm.cs | 3 ++- .../BookmarksCommandProvider.cs | 4 ++-- .../Microsoft.CmdPal.Ext.Bookmark/OpenInTerminalCommand.cs | 3 ++- .../cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/UrlCommand.cs | 7 ++++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarkPlaceholderForm.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarkPlaceholderForm.cs index f5a5745e1b..fedeb61467 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarkPlaceholderForm.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarkPlaceholderForm.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Text; using System.Text.Json.Nodes; using System.Text.RegularExpressions; +using ManagedCommon; using Microsoft.CmdPal.Ext.Bookmarks.Properties; using Microsoft.CommandPalette.Extensions.Toolkit; using Windows.System; @@ -101,7 +102,7 @@ internal sealed partial class BookmarkPlaceholderForm : FormContent } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine($"Error launching URL: {ex.Message}"); + Logger.LogError(ex.Message); } return CommandResult.GoHome(); diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarksCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarksCommandProvider.cs index 1ecf748a70..7045b05867 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarksCommandProvider.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarksCommandProvider.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using ManagedCommon; using Microsoft.CmdPal.Ext.Bookmarks.Properties; using Microsoft.CmdPal.Ext.Indexer; using Microsoft.CommandPalette.Extensions; @@ -97,8 +98,7 @@ public partial class BookmarksCommandProvider : CommandProvider } catch (Exception ex) { - // debug log error - Debug.WriteLine($"Error loading commands: {ex.Message}"); + Logger.LogError(ex.Message); } if (_bookmarks == null) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/OpenInTerminalCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/OpenInTerminalCommand.cs index 32284d617b..1ea5016cf4 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/OpenInTerminalCommand.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/OpenInTerminalCommand.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using ManagedCommon; using Microsoft.CmdPal.Ext.Bookmarks.Properties; using Microsoft.CommandPalette.Extensions; using Microsoft.CommandPalette.Extensions.Toolkit; @@ -34,7 +35,7 @@ internal sealed partial class OpenInTerminalCommand : InvokableCommand } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine($"Error launching Windows Terminal: {ex.Message}"); + Logger.LogError(ex.Message); } return CommandResult.Dismiss(); diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/UrlCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/UrlCommand.cs index 0b161a094e..c641006730 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/UrlCommand.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/UrlCommand.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using ManagedCommon; using Microsoft.CommandPalette.Extensions.Toolkit; using Windows.System; @@ -44,7 +45,7 @@ public partial class UrlCommand : InvokableCommand } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine($"Error launching URL: {ex.Message}"); + Logger.LogError(ex.Message); } return CommandResult.Dismiss(); @@ -87,9 +88,9 @@ public partial class UrlCommand : InvokableCommand return faviconUrl; } } - catch (UriFormatException) + catch (UriFormatException ex) { - // return "🔗"; + Logger.LogError(ex.Message); } return "🔗"; From ed505f0cb63a8d2846afbd4c1138fd9e6dee47ea Mon Sep 17 00:00:00 2001 From: vanzue Date: Fri, 9 May 2025 14:28:30 +0800 Subject: [PATCH 3/4] registry exception log --- .../Commands/OpenKeyInEditorCommand.cs | 7 ++++--- .../Helpers/RegistryHelper.cs | 4 +++- .../Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/OpenKeyInEditorCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/OpenKeyInEditorCommand.cs index d10b994318..b963c051bf 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/OpenKeyInEditorCommand.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/OpenKeyInEditorCommand.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Resources; using System.Text; using System.Threading.Tasks; +using ManagedCommon; using Microsoft.CmdPal.Ext.Registry.Classes; using Microsoft.CmdPal.Ext.Registry.Helpers; using Microsoft.CmdPal.Ext.Registry.Properties; @@ -37,7 +38,7 @@ internal sealed partial class OpenKeyInEditorCommand : InvokableCommand RegistryHelper.OpenRegistryKey(entry.Key?.Name ?? entry.KeyPath); return true; } - catch (System.ComponentModel.Win32Exception) + catch (System.ComponentModel.Win32Exception ex) { // TODO GH #118 We need a convenient way to show errors to a user // MessageBox.Show( @@ -45,13 +46,13 @@ internal sealed partial class OpenKeyInEditorCommand : InvokableCommand // Resources.OpenInRegistryEditorAccessExceptionTitle, // MessageBoxButton.OK, // MessageBoxImage.Error); + Logger.LogError(ex.Message); return false; } #pragma warning disable CS0168, IDE0059 catch (Exception exception) { - // TODO GH #108: Logging - // Log.Exception("Error on opening Windows registry editor", exception, typeof(Main)); + Logger.LogError(exception.Message); return false; } #pragma warning restore CS0168, IDE0059 diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/RegistryHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/RegistryHelper.cs index f010793c20..6e3eee7ef1 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/RegistryHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/RegistryHelper.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; - +using ManagedCommon; using Microsoft.CmdPal.Ext.Registry.Classes; using Microsoft.CmdPal.Ext.Registry.Constants; using Microsoft.CmdPal.Ext.Registry.Properties; @@ -201,12 +201,14 @@ internal static class RegistryHelper } catch (Exception exception) { + Logger.LogError(exception.Message); list.Add(new RegistryEntry($"{parentKey.Name}\\{subKey}", exception)); } } } catch (Exception ex) { + Logger.LogError(ex.Message); list.Add(new RegistryEntry(parentKey.Name, ex)); } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs index 791d242d00..16e6faab9c 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; - +using ManagedCommon; using Microsoft.CmdPal.Ext.Registry.Classes; using Microsoft.CmdPal.Ext.Registry.Commands; using Microsoft.CmdPal.Ext.Registry.Constants; @@ -96,6 +96,7 @@ internal static class ResultHelper } catch (Exception valueException) { + Logger.LogError(valueException.Message); var registryEntry = new RegistryEntry(key.Name, valueException); resultList.Add(new ListItem(new OpenKeyInEditorCommand(registryEntry)) @@ -140,6 +141,7 @@ internal static class ResultHelper } catch (Exception exception) { + Logger.LogError(exception.Message); var registryEntry = new RegistryEntry(key.Name, exception); resultList.Add(new ListItem(new OpenKeyInEditorCommand(registryEntry)) From e74c88f853811846e3ff45d191a5c869632318e1 Mon Sep 17 00:00:00 2001 From: vanzue Date: Fri, 9 May 2025 14:33:57 +0800 Subject: [PATCH 4/4] fix --- .../ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs | 1 + .../Microsoft.CmdPal.Ext.Registry.csproj | 1 + 2 files changed, 2 insertions(+) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs index b549781b56..c38c05d7b5 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs @@ -15,6 +15,7 @@ using Microsoft.CmdPal.Ext.Apps.Utils; using Microsoft.CommandPalette.Extensions.Toolkit; using static Microsoft.CmdPal.Ext.Apps.Utils.Native; using PackageVersion = Microsoft.CmdPal.Ext.Apps.Programs.UWP.PackageVersion; +using Theme = Microsoft.CmdPal.Ext.Apps.Utils.Theme; namespace Microsoft.CmdPal.Ext.Apps.Programs; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Microsoft.CmdPal.Ext.Registry.csproj b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Microsoft.CmdPal.Ext.Registry.csproj index c7633d7356..e800b4283a 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Microsoft.CmdPal.Ext.Registry.csproj +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Microsoft.CmdPal.Ext.Registry.csproj @@ -14,6 +14,7 @@ +