Skip to main content

Documentation Index

Fetch the complete documentation index at: https://ancplua.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Source: Al0104PreferAwaitUsingAnalyzer.cs

Description

When a type implements IAsyncDisposable, using using instead of await using calls the synchronous Dispose() method, potentially blocking or skipping async cleanup.

Bad Code

async Task Process()
{
    using var conn = new SqlConnection(connString);
    await conn.OpenAsync();
}

Good Code

async Task Process()
{
    await using var conn = new SqlConnection(connString);
    await conn.OpenAsync();
}

Properties

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

Configuration

dotnet_diagnostic.AL0104.severity = warning