ReSharper 2026.1 Help

Code inspection: Return of a task produced by 'using'-captured object

This inspection reports returning a task that was created from an object declared in a using scope. The object can be disposed before the returned task finishes using it.

Example

using System.IO; using System.Threading.Tasks; Task<string> ReadAsync(string path) { using var reader = File.OpenText(path); return reader.ReadToEndAsync(); }
using System.IO; using System.Threading.Tasks; async Task<string> ReadAsync(string path) { using var reader = File.OpenText(path); return await reader.ReadToEndAsync(); }
01 April 2026