The Disposable Transition Components page provides additional information about this warning and reports:
This warning can be safely ignored when: Dispose application code is called.
In the case of the Web API, the Web API framework registers the controllers for deletion, so this warning can be safely ignored for the Web API controllers.
Although the lifestyle of Web API controllers can be safely extended to a per-web-api request, itβs generally better to leave your root objects transient. Lifestyle promotion would force you to encourage the lifestyle of these addictions, and also make every sign-up in the app at least for a web request. Although it can be done safely without any problems, it can make your registration a little more complicated and can affect the speed with which large graphs of objects are allowed.
So the warning is false in your case. It can be safely ignored. It would be nice if the integration libraries suppressed these warnings. I just created a work item for this . Expect it to be fixed in a future release.
You can use the following code to suppress these warnings:
var results = from result in Analyzer.Analyze(container) let disposableController = result is DisposableTransientComponentDiagnosticResult && typeof(ApiController).IsAssignableFrom(result.ServiceType) where !disposableController select result; results.Should().HaveCount(0, String.Join(Environment.NewLine, results.Select(x => x.Description)));
source share