Releases: simpleinjector/SimpleInjector
Simple Injector v5.3.1
This release is available through Nuget.
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 patch fixes a caching bug in GetRegistration
, which could cause a a call to GetRegistration
or GetService
to invalidly return null
.
- #909 A call to
GetRegistration(Type)
andGetRegistration<T>()
would returnnull
, even after that type was registered, whenGetRegistration
was called before that registration was made. - #909 A call to
GetService(Type)
would returnnull
instead of the registered service, when a call toGetRegistration
was made before the registration was made.
Simple Injector v5.3
This release is available through Nuget.
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 contains the following improvements and new features:
- #897 Added a new convenient
Container.GetTypesToRegister<T>(IEnumerable<Assembly>, TypesToRegisterOptions)
overload. - #891
Container.GetRegistration<T>()
failed with cast exception. This generic overload was added in v5.0, but almost never worked. - #863 Loosened up locking behavior of
GetRegistration
. A call toGetRegistration
is now much less likely to cause the container to be locked. Thanks to @AroglDarthu for suggesting this. - #880 Allowed an existing
Scope
to be provided to aScopedLifestyle
to allow it to become the current active ambient scope. This feature was especially added for corner-case scenarios, such as Blazor integration. - #812 Improved exception messages caused by type initialization. TypeInitializationExcpetions, thrown by the .NET Framework are annoying and not very useful. When such exception is thrown while Simple Injector is resolving a type, Simple Injector will now transform the failure in a much more readable error message.
- #864 Improved the message of the Disposable-Transient-Component diagnostic warning. Thanks to @AroglDarthu for suggesting this.
Simple Injector v5.2.1
This release is available through Nuget.
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 patch fixes a concurrency bug that was introduced in v5.2.0 and impacts users of all builds except .NET Standard 2.1. All v5.2.0 users are advised to upgrade to this patch release.
- #883 Intermittently receiving IndexOutOfBoundsException from AsyncDisposableTypeCache.IsAsyncDisposable in 5.2.0
Simple Injector v5.2
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.
Simple Injector v5.1
This release is available through Nuget.
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.2.x release.
This minor release adds two new features to the core library:
- #857
Collection.Append
andCollection.Register
can now be called while supplying both a lifestyle and open generic implementations. - #861
DependencyMetadata<T>
can now be used in conjunction with Flowing scopes.
Thanks to @henriblMSFT for providing high-quality feature requests that made this possible.
Simple Injector v5.0.4
Simple Injector v5.0.4 is available through Nuget.
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.2.x release.
This patch release fixes three bugs:
- #850 Conditional registrations can now be made when
AllowOverridingRegistrations
is set to true - #836 Conditionally register instances of the same type can now be registered (thanks to @kwlin)
- #859 When calling
Lifestyle.Singleton.CreateRegistration
using aFunc<object>
delegate, C# overload resolution would cause the incorrectCreateRegistration
overload to be called.
Simple Injector v5.0.3
Simple Injector v5.0.3 is available through Nuget.
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.2.x release.
This patch release improves reporting of duplicate registrations during Auto-Registration in case the same assembly is (accidentally) loaded twice (while the runtime considers them separate assemblies). Simple Injector will now report (through an exception message) that the assembly is loaded more than once and it describes how to solve this problem.
Simple Injector v5.0.2
Simple Injector v5.0.2 is available through Nuget.
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.2.x release.
This patch release fixes issue #829 and allows collections with Scoped dependencies be resolved from a Scope when the 'Flowing' scoping model is used.
Simple Injector v5.0
Release Notes
Simple Injector v5 is available through Nuget. For more background information about this release and a general overview, please read the blog post.
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.2.x release.
For the release notes of the ASP.NET Core integration packages, go here.
Overview
The most prominent changes and improvements in this release are:
- #692 No more .NET 4.0. We decided to drop support for the legacy version 4.0 of the .NET Framework. Minimum supported versions are .NET 4.5 and .NET Standard 1.0.
- #557 No more first-chance exceptions. The chance of having your IDE stop at an exception that can safely be continued (a first-chance exception), are now much smaller.
- #747 Container is now automatically verified when first resolved. More information in the docs.
- #780 Unregistered concrete types are no longer resolved.
- #747 Simplified registration of disposable components. Disposables can now more easily be registered using
Lifestyle.Scoped
because Simple Injector now allowsTransient
dependencies to be injected without causing verification errors. - #820: Registration/startup performance improved. We managed make your application load faster. In extreme cases startup performance is improved up to 60%.
- #791 Asynchronous disposal.
Container
andScope
classes now implementIAsyncDisposable
to allow asynchronous disposal of components (only in .NET 4.6.1, .NET Standard 2.0, and .NET Standard 2.1 versions) - #393 Injection of metadata. In more advanced scenarios, infrastructural components can benefit from receiving additional metadata for injected components. You can now out-of-the-box inject
SimpleInjector.DependencyMetadata<TService>
into your infrastructural components to get the actual implementation type, even when that component is intercepted with decorators. This also works for collections.
Breaking changes
Below you find the complete list of all the breaking changes in the core library and all officially supported integration libraries.
Simple Injector core library
- #747 Verification is now automatically performed upon the very first call to
GetInstance()
. You will be affected if you purposely skipped verifying the container. This behavior can be disabled by settingContainer.Options.EnableAutoVerification = false;
- #694 When calling
RegisterConditional
, thePredicateContext.Consumer
property will now never return null, but instead it throws an exception. Use the newPredicateContext.HasConsumer
property instead of checking for null. You will be affected when you checkedPredicateContext.Consumer
fornull
. - #816 Verification now allows Transient components to be injected into Scoped components by default. This behavior can be disabled by setting
Container.Options.UseStrictLifestyleMismatchBehavior = true
- #393 The
where TService : class
type constraint was removed fromInstanceProducer<TService>
InstanceProducer
constructor became obsolete.- #700 Decorating container-uncontrolled collections with a singleton decorator will now throw an exception.
- #692 Removed support for .NET 4.0.
- #557
ConstructorInfo GetConstructor(Type)
method ofIConstructorResolutionBehavior
interface replaced withConstructorInfo? TryGetConstructor(Type, out string?)
method. You will be affected when you replaced the default constructor resolution behavior. - #557
void Verify(InjectionConsumerInfo)
method ofIDependencyInjectionBehavior
interface replaced withbool VerifyDependency(InjectionConsumerInfo, out string?)
method. You will be affected when you replaced the default dependency injection behavior. - #780 Unregistered concrete types will not be resolved any longer. You will be affected when your configuration depends on unregistered concrete types. This behavior can be disabled by setting
Container.Options.ResolveUnregisteredConcreteTypes = true;
. - #275
Options.EnableDynamicAssemblyCompilation
is now obsolete and replaced with a newOptions.ExpressionCompilationBehavior
. - #809 Several obsoleted methods and classes that previously caused compile errors (due to the use of the
ObsoleteAttribute
) have been removed. To prevent any problems, make sure you upgrade to the latest v4.x release first before upgrading to v5. Only upgrade to v5 after fixing all compiler warnings and errors . - #810 Several obsoleted properties, methods, and classes that where marked as obsoleted are now marked with
Obsolete(error: true)
which will cause a compiler error when used:- All
AdvancedExtensions
methods (IsLocked
,IsVerifying
,GetItem
,SetItem
,GetOrSetItem<T>
, andAppendToCollection
) Container.RegisterCollection
overloads (they have been replaced withContainer.Collection.Register
)Container.RegisterSingleton
overloads for registering already existing instances (they have been replaced withContainer.RegisterInstance
methods)Scope
's default constructor
- All
- #820:
Lifestyle
: protectedLifestyle.CreateRegistrationCore<T>(Container)
method removed. You should now inherit fromLifestyle.CreateRegistrationCore(Type, Container)
. It has the same semantics. - #820:
Registration
:Type implemenationType
andFunc<object> instanceCreator = null
parameters added toRegistration
constructor. You will be affected when you developed a custom lifestyle. - #820:
Registration
:BuildTransientDelegate<TService>(Func<TService>)
removed. You can callBuildTransientDelegate()
instead. You will be affected when you developed a custom lifestyle. - #820:
Registration
:BuildTransientExpression<TService>(Func<TService>)
removed. You can callBuildTransientExpression()
instead. You will be affected when you developed a custom lifestyle.
Packaging, WCF, Web, and Web API Integration
- #809 Several obsoleted methods and classes have been removed. To prevent any problems, make sure you upgrade to the latest v4.x release first before upgrading to v5. Only upgrade to v5 after fixing all compiler warnings and errors
API changes
Simple Injector core library
- #229
Lifestyle.Singleton.CreateRegistration(Type, object, Container)
method added for the creation ofRegistration
instances for already-created instances, including value types. - #694
PredicateContext.HasConsumer
property added to see whether there is a consumer or the type is being resolved directly from the container. - #816
Options.UseStrictLifestyleMismatchBehavior
property added that replaces the oldOptions.UseLoosenedLifestyleMismatchBehavior
. - #393
InstanceProducer.ImplementationType
property added. - #393
DependencyMetadata<TService>
class added. You can now inject aDependencyMetadata<TService>
orIEnumerable<DependencyMetadata<TService>>
into a consumer to get metadata about the injected dependency. - #791
Container
now implementsIAsyncDisposable
(only in .NET 4.6.1, .NET Standard 2.0, and .NET Standard 2.1 versions). - #791
Scope
now implementsIAsyncDisposable
(only in .NET 4.6.1, .NET Standard 2.0, and .NET Standard 2.1 versions). - #557 static
DependencyInjectionBehaviorExtensions
class added withVerify
extension method to mimic the old behavior ofIDependencyInjectionBehavior
. - #557 static
ConstructorResolutionBehaviorExtensions
class added withGetConstructor
extension method to mimic the old behavior ofIConstructorResolutionBehavior
. - #810
Container.IsLocked
property added.
API Difs
- SimpleInjector
- SimpleInjector.Integration.Wcf
- SimpleInjector.Integration.Web
- SimpleInjector.Integration.WebApi
Complete list of bugs, features and improvements
-#229 Remove the reference-type restriction from Container.RegisterConditional
and Lifestyle.CreateRegistration
- #747 Enable Automatically perform verification upon first resolve by default.
- #694 Prevent
PredicateContext.Consumer
from returning null. - #816 Make 'loosened lifestyle mismatch behavior' the default.
- #393 Allow dependency to be injected with additional metadata.
- #791 Add
IAsyncDisposable
integration usingScope.AsyncDispose
andContainer.AsyncDispose
. - #700 Drop support for decorating uncontrolled collections using a singleton decorator.
- #692 Remove support for .NET 4.0.
- #557 Prevent first-chance exceptions.
- #589 Allow the registration and resolving of ActiveX / Proxy instances.
- #780 Disable resolving concrete types by default.
- #275 Move Dynamic Assembly Compilation to different assembly.
- #820 Improve startup/configure performance by replacing.
Lifestyle.CreateRegistrationCore<T>(Container)
withLifestyle.CreateRegistrationCore(Type, Container)
. - #818 Unresolved conditional root types lead to confusing exception message
- #815 Resolving a stream collection always resolves the first instance
Simple Injector v4.10.3
Release Notes
Simple Injector can be downloaded using NuGet.
This patch release only updates the SimpleInjector.Integration.ServiceCollection
library. No new NuGet package is published for the core library and other unrelated integration packages.