This release is available through Nuget.
WARNING: There was a multi-threading bug introduced in this release that could impact most users. Please skip this release and upgrade to (at least) v5.2.1.
When upgrading from v4.x, please make sure you upgrade your application to the latest v4.x version of Simple Injector first. After that upgrade directly to the latest v5.3.x release.
This minor release implements the following work items:
- #873 Verification fails with
IAsyncDisposable
registrations - #867 Prevent
Microsoft.Bcl.AsyncInterfaces
dependency
The most important change in this minor release is #867, which solves the binding redirect issues that users have reported since the introduction of v5. This is done by removing the Microsoft.Bcl.AsyncInterfaces
NuGet package dependency (#867). Unfortunately, this forces the following breaking changes in the core library:
- [BREAKING] The
Scope.RegisterForDisposal(IAsyncDisposable)
method is removed and replaced with aScope.RegisterForDisposal(object)
overload. - [BREAKING] In the .NET Standard 2.0 and .NET 4.6.1 builds of Simple Injector,
Container
andScope
no longer implementIAsyncDisposable
effectively removingContainer.DisposeAsyc()
andScope.DisposeAsync()
from those builds.
These breaking changes were required because the removal of the Microsoft.Bcl.AsyncInterfaces
dependency disallows Simple Injector types to implement IAsyncDisposable
. Fortunately, unless you were calling DisposeAsync
yourself, an upgrade to Simple Injector v5.2 is likely a graceful one. For a more detailed discussion on what the problem was, please read our blog post.
The problem was urgent enough to force these breaking changes on a minor release, instead of making this into a major release, which takes much more planning and time.
NOTE: Do note that if you are using ASP.NET Core, you must upgrade the ASP.NET Core integration packages as well. The old packages will break with v5.2.
This doesn't mean, though, that asynchronous disposal isn't possible anymore. On the contrary actually. Where previous minor releases only allowed asynchronous disposal in the .NET 4.6.1, .NET Standard 2.0, and .NET Standard 2.1 builds of Simple Injector, asynchronous disposal is now supported in all builds. To make this possible, the following additions have been made:
- The pre-.NET Standard 2.1 builds of Simple Injector apply duck typing internally to recognize types that implement
IAsyncDisposable
. This means that Simple Injector checks if your type implements an interface named "System.IAsyncDisposable". Upon disposal, Simple Injector expects that interface to contain anDisposeAsync
method. That method should either returnTask
, orValueTask
. This means that you can either let your application depend onMicrosoft.Bcl.AsyncInterfaces
or define the interface yourself. As always, we ensured maximum performance; even this duck typing is blazingly fast. - The .NET Standard 2.1 build of Simple Injector skips duck typing and simply expects a asynchronous disposable type to implement the official
IAsyncDisposable
. .NET Standard 2.1 (which means you're either running .NET Core 3 or .NET 5) is provided out of the box. - A new
Task Container.DisposeContainerAsync()
method is added to allow disposing of theContainer
in an asynchronous fashion. - A new
Task Scope.DisposeScopeAsync()
method is add to allow disposing of theScope
in an asynchronous fashion. - A new
object[] Scope.GetAllDisposables()
method is added to allow retrieving all disposables instances that were created by aScope
. The list will return bothIDisposable
andIAsyncDisposable
implementations.