@dotnetjunkie dotnetjunkie released this Mar 31, 2017 · 46 commits to v4.0.x since this release

Assets 2

Release Notes

Simple Injector v4 is available through Nuget. For more background information about this release and a general overview, please read the blog post.

Before you upgrade to v4.0, please make sure you upgrade your application to the latest 3.x version of Simple Injector first.

Features and improvements

Simple Injector core library

  • ThreadScopedLifestyle added to core library as replacement of LifetimeScopeLifestyle. This is purely a name change, it behaves identical to the old LifetimeScopeLifestyle. The SimpleInjector.Extensions.LifestyleScoping package has been deprecated. (fixes #299)

  • AsyncScopedLifestyle added to core library as replacement of ExecutionContextScopeLifestyle. This is purely a name change, it behaves identical to the old ExecutionContextScopeLifestyle. The SimpleInjector.Extensions.ExecutionContextScoping package has been deprecated. (fixes #299)

  • TypesExtensions class added with useful extension methods on Type: ToFriendlyName,
    IsClosedTypeOf, GetClosedTypeOf and GetClosedTypesOf methods. (fixes #358)

  • Container.AddRegistration(Registration) method added. (fixes #367)

  • Lifestyle.CreateHybrid overloads added for ScopedLifestyles that remove the need to supply
    an lifestyleSelector delegate. (fixes #341)

  • InstanceProducer.FromExpression() added to simplify wrapping Expression instances. (fixes #346)

  • Stack trace added to exception that gets thrown when container got disposed. (fixes #368)

  • Clear exception is thrown when invalid Expression is passed on to
    ExpressionBuildingEventArgs.Expression. (fixes #354)

  • Improved exception message when registering generic types with type constraints while in
    overriding mode. (fixes #384)

  • Improved exception message thrown when RegisterCollection is called twice. (fixes #378)

SimpleInjector.Integration.AspNetCore

  • GetRequestService and GetRequiredRequestService extension methods added for IApplicationBuilder to simplify resolving instances from the ASP.NET configuration system, while
    their lifestyle is preserved. See the ASP.NET Core integration guide for more information.

SimpleInjector.Packaging

  • GetPackagesToRegister extension method added to simplify retrieving packages.

Breaking changes

Simple Injector core library

  • Registration instances will now get cached to prevent torn lifestyles. (fixes #219)

  • Short Circuited Dependency warning will now go off as well for transient registrations. (fixes #248)

  • Container.RegisterInitializer(Action<InstanceInitializationData>, Predicate<InitializationContext>)
    replaced with RegisterInitializer(Action<InstanceInitializationData>, Predicate<InitializerContext>)
    method. (fixes #348)

  • IConstructorResolutionBehavior.GetConstructor(Type, Type) signature changed to
    GetConstructor(Type). (fixes #345)

  • ILifestyleSelectionBehavior.SelectLifestyle(Type, Type) signature changed to
    SelectLifestyle(Type). (fixes #345)

  • IDependencyInjectionBehavior.BuildExpression method replace with
    GetInstanceProducer(InjectionConsumerInfo, bool) that returns an InstanceProducer (fixes #346)

  • IPropertySelectionBehavior.SelectProperty(Type serviceType, PropertyInfo) replaced with
    SelectProperty(Type implementationType, PropertyInfo) method. (fixes #348)

  • Lifestyle.CreateRegistration<TService, TImplementation>(Container) signature changes to CreateRegistration(Container). (fixes #345)

  • Lifestyle.CreateRegistration(Type, Type, Container) signature changes to
    CreateRegistration(Type, Container). (fixed #345)

  • Lifestyle.CreateRegistrationCore<TService, TImplementation>(Container) signature changes to
    CreateRegistrationCore(Container). (fixes #345)

  • Lifestyle.Length property made public to simplify creating custom lifestyles. (fixes #245)

  • ExpressionBuildingEventArgs.RegisteredServiceType removed. (fixes #348)

  • InjectionConsumerInfo.ServiceType removed. (fixes #348)

  • Registration.BuildTransientExpression<TService, TImplementation>() signature changed to
    BuildTransientExpression(). (fixes #345)

  • Registration.BuildTransientDelegate<TService, TImplementation>() signature changed to
    BuildTransientDelegate(). (fixes #345 / #348)

SimpleInjector.Extensions.LifetimeScoping

SimpleInjector.Extensions.ExecutionContextScoping

  • This package has been deprecated and will no longer be maintained. All functionality has been merged into the core library. (fixes #299)
  • ExecutionContextScopeLifestyle has been deprecated. Users should use the new SimpleInjector.Lifestyles.AsyncScopedLifestyle. (fixes #299)

SimpleInjector.Integration.AspNetCore

  • AspNetRequestLifestyle has been deprecated. Users should use the new SimpleInjector.Lifestyles.AsyncScopedLifestyle.
  • UseSimpleInjectorAspNetRequestScoping extension method for IApplicationBuilder has been deprecated. Users should now use the overload for IServiceCollection instead. See the integration guide for more information.

SimpleInjector.Integration.Wcf

  • SimpleInjectorWcfExtensions methods that were deprecated in v3 have now been removed completely. (fixes #305)
  • SimpleInjectorWcfExtensions.RegisterPerWcfOperation marked obsolete.
  • WcfOperationLifestyle methods that were deprecated in v3 have now been removed completely. (fixes #326)
  • RegisterPerWcfOperation and GetCurrentWcfOperationScope marked with Obsolete(true) causing them to trigger. (fixes #304)

SimpleInjector.Integration.Web

  • SimpleInjectorWebExtensions and WebRequestLifestyle methods that were deprecated in v3 have now been removed completely. (fixes #326)
  • RegisterPerWebRequest marked with Obsolete(true). (fixes #304)

SimpleInjector.Integration.Web.Mvc

  • SimpleInjectorMvcExtensions methods that were deprecated in v3 have now been removed completely. (fixes #305)

SimpleInjector.Integration.WebApi

SimpleInjector.Packaging

  • RegisterPackages(Container) method marked obsolete. The overload that accepts a list of Assembly instances should be used instead. (fixes #372)

Bug fixes

  • Prevented RegisterConditional predicates from always being called twice. (fixes #346)
  • Allowed properties to be injected on conditional registrations, in case custom property injection behavior is applied. (fixes #383)
  • Open-generic abstractions with a "new()" type constraint would be incorrectly flagged as
    conditional, making it impossible to replace those registrations. (fixes #387)