Skip to content

[Analyzer] Unawaited / returned tasks created with a disposable in using block for that disposable #78394

Open
dotnet/roslyn-analyzers
#7549
@stephentoub

Description

Consider code like the following:

public Task MyMethodAsync()
{
    using (SomeIDisposable disposable = new SomeIDisposable())
    {
        ...
        return SomethingAsync(disposable); // or fire-and-forget
    }
}

There's a high likelihood that this Task-returning SomethingAsync will be using the SomeIDisposable instance long after it's been disposed. We should consider an analyzer that flags such situations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-System.Threading.Taskscode-analyzerMarks an issue that suggests a Roslyn analyzerhelp wanted[up-for-grabs] Good issue for external contributors

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions