Skip to main content
ai-slop/csharp-sync-over-asyncmanual fix

Sync over async.

Blocking on a task with `.Result`, `.Wait()`, or `.GetAwaiter().GetResult()`. It ties up a thread and can deadlock under a synchronization context.

Flagged shape and clean shape.

Each example shows the exact code shape the rule is looking for, then the smallest version that keeps the intent without hiding risk or adding noise.

csharp-sync-over-async.cs
✗ Flagged
public User GetUser(int id)
{
    return _client.GetUserAsync(id).Result;
}
Why this trips

Deterministic line match on masked source: flags `.Result` member access, `.Wait()`, and `.GetAwaiter().GetResult()`.

csharp-sync-over-async.cs
✓ Clean
public async Task<User> GetUserAsync(int id)
{
    return await _client.GetUserAsync(id);
}
What changed

`await` the task and make the caller async. If you genuinely hold a completed task and must block, add a short comment naming that invariant.

When an async API has to be called from synchronous code, agents block on it instead of making the caller async. It works in a quick test and deadlocks in UI or classic ASP.NET contexts.

How this rule is justified.

Rule id

ai-slop/csharp-sync-over-async

Enforcing engine

ai-slop

Detector strategy

Deterministic line match on masked source: flags `.Result` member access, `.Wait()`, and `.GetAwaiter().GetResult()`.

Legitimate code that is NOT flagged

Calls with a `//` comment on either of the two lines above (stating why blocking is safe), and `.Wait(...)` overloads that take arguments, are not flagged.

Evidence

Part of aislop's C# rule set. First-class C# support, including C#-specific AI-slop rules, arrived in aislop v0.14.1.