Skip to content

Fix async void exception handling in command execute methods#3882

Open
Moli13337 wants to merge 1 commit into
icsharpcode:masterfrom
Moli13337:fix-async-void-exception-handling
Open

Fix async void exception handling in command execute methods#3882
Moli13337 wants to merge 1 commit into
icsharpcode:masterfrom
Moli13337:fix-async-void-exception-handling

Conversation

@Moli13337

Copy link
Copy Markdown

Fixes critical exception handling issues in command Execute methods where async void was used, causing unhandled exceptions that could crash the application.

Changes

  • FileCommands.cs: Fixed OpenCommand.Execute and SaveCommand.Execute
  • AssemblyTreeNode.cs: Fixed LoadDependencies.Execute

What was fixed?

Previously, these methods used async void which:

  • Cannot be awaited by callers
  • Swallows exceptions (causes application crashes)
  • Makes testing difficult

Now they use the project's standard fire-and-forget pattern:

  • Synchronous void Execute (maintains interface compatibility)
  • Async logic extracted to Task ExecuteAsync
  • Uses HandleExceptions() to route errors to GlobalExceptionHandler
  • Matches 30+ existing usages throughout the project

async void methods in command Execute handlers can cause unhandled exceptions that crash the application. This fix extracts the async logic into Task-returning methods and uses HandleExceptions() to ensure exceptions are properly caught and routed to GlobalExceptionHandler, matching the fire-and-forget pattern used throughout the project.

Assisted-by: Claude:claude-opus-4-8:Claude Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant