🤖 The Prompt That Reads Your Async Code the Way a Deadlock Eventually Would
Missing ConfigureAwait(false) calls in library code, and synchronous blocking on an async call with .Result or .Wait(), are two of the most common causes of hard-to-reproduce deadlocks in .NET – and both are easy for a human reviewer to skim right past, because the code still compiles and still works most of the time. Feeding a batch of async methods to an AI model with a prompt specifically trained on these two patterns turns a tedious, error-prone manual audit into a quick first pass that flags exactly the lines worth double-checking before they cause a production hang.
🔎 The Problem
You are reviewing C# code for async/await correctness. For each file or method I paste, check specifically for: 1. Any .Result, .Wait(), or .GetAwaiter().GetResult() call on a Task or Task<T> - flag it as a potential sync-over-async deadlock risk, especially if it appears to run in a context with a synchronization context (ASP.NET classic, WPF, WinForms). 2. Any await call inside a method intended for use as a reusable library (not an application entry point or ASP.NET Core controller action) that is missing .ConfigureAwait(false). 3. Any async method whose name doesn't end in "Async" by convention, which can hide the fact that it needs to be awaited at all. For each finding, show: the exact line, why it's risky, and the minimal one-line fix. Don't flag ConfigureAwait(false) as missing in ASP.NET Core application code itself (where it's unnecessary), only in reusable library/shared code. Code to review: [paste your C# file(s) here]
✅ Why This Prompt Works
- It gives the model a narrow, specific checklist instead of a vague ‘review this code’ request, which is exactly what keeps an AI code review focused and keeps the false-positive rate manageable.
- It explicitly distinguishes library code from application code for the ConfigureAwait rule, which matters because that same advice given indiscriminately produces noisy, wrong suggestions in ASP.NET Core controller actions.
- Asking for the minimal fix alongside each finding turns the output into something you can act on directly, rather than a list of problems you still have to go research the solution for.
⚠️ Getting the Most Out of It
- Paste real files rather than isolated snippets where possible – sync-over-async deadlocks are often only visible when you can see what calls a method and whether that caller is itself running on a thread with a synchronization context.
- Treat the output as a prioritized list to manually verify, not a guaranteed bug report – an AI model can still misjudge whether a given call site actually has a synchronization context to deadlock against.
A deadlock from mixing sync and async code doesn’t announce itself in code review – it waits for production load, and by then it’s not a review comment anymore, it’s an incident.





