Skip to main content
Source: AL0112FireAndForgetTaskAnalyzer.cs

Description

Discarding a Task with _ = SomeAsyncMethod() causes fire-and-forget behavior where exceptions thrown by the asynchronous operation are silently lost. This makes failures invisible and can lead to data corruption, resource leaks, or cascading issues that are extremely difficult to diagnose in production. The analyzer detects assignments where the target is a discard (_) and the value is an invocation returning Task, Task<T>, ValueTask, or ValueTask<T>.

Bad Code

Good Code

Properties

  • Category: Reliability
  • Severity: Warning
  • Enabled by default: True
  • Code fix available: False

Configuration