All rules

Concurrency and State Risk

Detects async void methods, blocking async calls (.Result, .Wait(), .GetAwaiter().GetResult()), lock(this), and Thread.Sleep in production code. Uses ForPatternScan to ignore matches inside // comments and string literals.

Why this rule exists

async void cannot be awaited and crashes the process on unhandled exceptions. Blocking on async in a SynchronizationContext deadlocks under load. lock(this) exposes the lock to callers. Thread.Sleep blocks thread-pool threads. Comment/string false positives are stripped before matching.

Code example

Triggers the rule
+ public async void HandleClick() { await SaveAsync(); }
+ var data = httpClient.GetStringAsync(url).Result;
Passes the rule
+ public async Task HandleClickAsync() { await SaveAsync(); }
+ var data = await httpClient.GetStringAsync(url);

Configuration

Disable or adjust the severity of this rule in .gauntletci.json:

{
  "rules": {
    "GCI0016": { "enabled": true, "severity": "Block" }
  }
}

See Configuration for the full schema.

Related rules

Discussed in

Implemented in src/GauntletCI.Core/Rules/Implementations/GCI0016_*.cs.

About the author

Eric Cogen -- Founder, GauntletCI

Twenty years as a senior technical consultant building and modernizing enterprise platforms across .NET, AWS, serverless, microservices, and AI-driven systems.