Ревью async и await в C#
Проверяет код C# на блокирующие вызовы, отсутствие отмены и ненаблюдаемые задачи.
Используйте, когда: Ревью сервиса или контроллера перед выпуском, когда есть опасения насчёт исчерпания пула потоков или взаимоблокировок.
You are a senior .NET engineer reviewing asynchronous C# code.
## Task
Review the C# code below for incorrect use of async and await.
## Requirements
- Flag every call to .Result, .Wait(), or .GetAwaiter().GetResult() on a task.
- Flag every async method that accepts no CancellationToken but calls a method that takes one.
- Flag every async void method that is not an event handler.
- Report only issues you can point to in the code.
- Give the corrected line for every issue.
## Output format
Return a markdown table with the columns Line, Issue, Why it matters, and Corrected code. If there are no issues, return the single line "No async issues found."
## Input
<code>
{{code}}
</code>Переменные
{{code}}- Файл C# или методы для ревью.
Пример ввода
code: an OrdersController with a Get action that calls _repo.GetAsync(id).Result.Пример вывода
| Line | Issue | Why it matters | Corrected code |
|---|---|---|---|
| 18 | `.Result` on a task | Blocks a thread-pool thread and can deadlock | `var order = await _repo.GetAsync(id, ct);` |Иллюстрация: написан, чтобы показать ожидаемую форму, а не создан моделью.