2

Closed

Prevent warning about 'disposable transient' in Web API and MVC controller registrations

description

The 2.7 release of Simple Injector added a new diagnostic warning named Disposable Transient Components. Unfortunately, this warning causes false-positives in case users use the RegisterWebApiControllers or RegisterMvcControllers extension methods. Technically the warning is correct, since those controllers are registered as transient, but both frameworks ensure that controllers are disposed when the request ends.

Therefore, those methods must be able to suppress the warnings on those registrations.

This issue was initially reported here.
Closed Apr 10, 2015 at 2:55 PM by dot_NET_Junkie

comments

dot_NET_Junkie wrote Mar 3, 2015 at 11:01 AM

This issue can be fixed after 21008 has been implemented. When Diagnostics is part of the core library, we will be able to do something as follows:
Registration r = [some registration]
r.SuppressWarning(DiagnosticType.DisposableTransientComponent);

dot_NET_Junkie wrote Mar 11, 2015 at 7:43 PM

Fixed in changeset bc2935912d4552fcb230aebf107949a25851d52a