Unnecessary async await (ARCH108)
هذا المحتوى غير متوفر بلغتك بعد.
Key dotnet.async.unnecessary-async-await · Severity info · Category async
When a method only awaits and returns a single Task, the async/await state machine adds needless overhead. Return the Task directly instead.
Incorrect
Section titled “Incorrect”public async Task<Order> GetOrderAsync(int id){ return await _repository.FindAsync(id);}Correct
Section titled “Correct”public Task<Order> GetOrderAsync(int id){ return _repository.FindAsync(id);}Remove async/await and return the Task directly (when there is no try/catch, using, or multiple awaits). If needed, suppress the rule per project/workspace via except/ignore.