That’s because compiler generates state machine from your async method, and that state machine class (named <Do>d__0
in this case) contains field of type Disposable
but does not itself implements IDisposable
interface. It doesn’t make much sense for analyzer to analyze compiler generated code (and this <Do>d__0
class is marked with CompilerGenerated
attribute). Fortunately, there is a setting for code analyzer to avoid compiler generated code: go to project properties, “Code Analysis” tab and check “Suppress results from generated code”, and this warning will go away.