diff --git a/ILSpy/Commands/FileCommands.cs b/ILSpy/Commands/FileCommands.cs index 016671924f..f8c3aa3f89 100644 --- a/ILSpy/Commands/FileCommands.cs +++ b/ILSpy/Commands/FileCommands.cs @@ -45,7 +45,7 @@ namespace ICSharpCode.ILSpy.Commands [method: ImportingConstructor] sealed class OpenCommand(AssemblyTreeModel assemblyTreeModel) : SimpleCommand { - public override async void Execute(object? parameter) + public override void Execute(object? parameter) { // Tests / scripted callers can pass paths directly and bypass the file picker. if (parameter is string singlePath) @@ -59,6 +59,11 @@ public override async void Execute(object? parameter) return; } + ExecuteAsync().HandleExceptions(); + } + + async Task ExecuteAsync() + { var owner = UiContext.MainWindow; if (owner == null) return; @@ -236,7 +241,12 @@ internal sealed class SaveCommand( public override bool CanExecute(object? parameter) => assemblyTreeModel.SelectedItem is ILSpyTreeNode; - public override async void Execute(object? parameter) + public override void Execute(object? parameter) + { + ExecuteAsync().HandleExceptions(); + } + + async Task ExecuteAsync() { // Several selected assemblies export a Visual Studio solution (one project each), // matching the Save Code context-menu entry. diff --git a/ILSpy/TreeNodes/AssemblyTreeNode.cs b/ILSpy/TreeNodes/AssemblyTreeNode.cs index ba94e57c51..f80576af25 100644 --- a/ILSpy/TreeNodes/AssemblyTreeNode.cs +++ b/ILSpy/TreeNodes/AssemblyTreeNode.cs @@ -675,7 +675,12 @@ public bool IsVisible(TextViewContext context) public bool IsEnabled(TextViewContext context) => true; - public async void Execute(TextViewContext context) + public void Execute(TextViewContext context) + { + ExecuteAsync(context).HandleExceptions(); + } + + async Task ExecuteAsync(TextViewContext context) { if (context.SelectedTreeNodes == null) return;