@dotnetjunkie dotnetjunkie released this Aug 18, 2015 · 632 commits to master since this release

Assets 3

Release Notes

Simple Injector v3 is available through Nuget, or you can download the .zip file here. For more background information about this release and migration guidance, please read the blog post. Also see the blog post for a cheat sheet with the most prominent breaking changes.

In Simple Injector v3.0 we are breaking with the past. We removed legacy methods, considerably simplified parts of the API, and added new compelling features.

What this means is that we expect that almost every developer will have to make changes to his composition root.

Before you upgrade to v3.0, please make sure you upgrade your application to the latest 2.8 version of Simple Injector first..

Most compelling new features for this release are the addition of the RegisterConditional method to make conditional and contextual registrations, and the addition of the Lifestyle.Scope Container.Options.DefaultScopedLifestyle pair to considerably simplify working with scoped lifestyles. The most prominent breaking changes are the replacement of the complete SimpleInjector.Extensions namespace and the rename of the methods RegisterSingle and RegisterAll to RegisterSingleton and RegisterCollection.

New features and improvements for the SimpleInjector.dll

  • Container class now implements IDisposable to allow disposing singletons. (fixes #5)
  • Added RegisterDecorator<TService, TDecorator>() methods to simplify registration of non-generic decorators (fixes #7)
  • Added RegisterDecorator() as instance methods on the Container class. (fixes #7)
  • Register(Type, Type) overloads now accept open-generic types as well. (fixes #7)
  • Added Container.GetTypesToRegister method for batch registration. This method was previously hidden deep in the SimpleInjector.Extensions namespace. (fixes #7)
  • Added Container.RegisterSingleton methods as replacement for RegisterSingle methods. The new method name is more intuitive. (fixes #44)
  • Added Container.RegisterCollection methods as replacement for RegisterAll. The new method name is more intuitive. (fixes #42)
  • InstanceProducer<TService> class added that inherits from InstanceProducer and adds a TService GetInstance() method. The generic Lifestyle.CreateProducer methods return an InstanceProducer<TService>. This simplifies the use of externally created instance producers. (fixes #39)
  • DiagnosticResult.Severity property added to allow differentiating between warnings and information messages. (fixes #9)
  • RegisterCollection(Type, IEnumerable<Registration>) now accepts open generic types as well. (fixes #22)
  • Added Container.Register(Type, IEnumerable<Assembly>) and Container.RegisterCollection(Type, IEnumerable<Assembly>) overloads for batch registration. (fixes #7)
  • Resolving variant collections is now supported for container-uncontrolled collections as well. (fixes #25)
  • RegisterConditional methods added to make conditional and contextual registrations for both non-generic and
    closed-generic and open-generic types. (fixes #4)
  • Improved the message of the Lifestyle Mismatch diagnostic warning to include the concrete type in the message. (fixes #63)
  • When overriding property injection behavior, property injection can be intercepted the using the IDependencyInjectionBehavior in the same way as constructor parameters can. (fixes #59)
  • Lifestyle.Scoped property added to simplify registration of scoped lifestyles. (fixes #38)
  • In case of a cyclic dependency graph, the thrown exception now includes information about the graph. (fixes #68)
  • ScopedLifestyle derivatives don't have to override Length anymore and all scoped lifestyles will have the same length. This will make the diagnostic services to treat them as the same lifestyle.
  • Improved support for huge object graphs. (fixes #91)

Breaking changes for the SimpleInjector.dll

  • Unregistered collections are not resolved as empty collections by default anymore. Collections need to be registered explicitly. You can fallback to the old v1/v2 behavior by calling container.Options.ResolveUnregisteredCollections = true;. (fixes #98)
  • IConstructorVerificationBehavior and IConstructorVerificationBehavior made obsolete and replaced with a new IDependencyInjectionBehavior abstraction that combines the two. (fixes #2)
  • Constructor overload Container(ContainerOptions) removed from Container. (fixes #40)
  • Made ScopedLifestyle.WhenScopeEnds method non-virtual. (fixes #11)
  • Made ScopedLifestyle.RegisterForDisposal method non-virtual. (fixes #11)
  • Made ScopedLifestyle.CreateCurrentScopeProvider method abstract. (fixes #11)
  • Removed ScopedLifestyle.DisposeInstances method. (fixes #11)
  • Removed Container.InjectProperties method. (fixes #12)
  • Removed the Container.RegisterSingle method overloads. (fixes #44)
  • Removed the Container.RegisterAll method overloads. (fixes #42)
  • Moved DecoratorPredicateContext class to the SimpleInjector root namespace. (fixes #7)
  • Moved DecoratorContext to the SimpleInjector root namespace. (fixes #7)
  • Removed RegisterSingleDecorator extension methods. RegisterDecorator can be used instead. (fixed #7)
  • Removed RegisterAllOpenGeneric extension methods. RegisterCollection can now be used instead. (fixes #7)
  • Removed RegisterOpenGeneric and RegisterSingleOpenGeneric extension methods. Register can now be used instead. (fixes #7)
  • Renamed OpenGenericPredicateContext to PredicateContext and moved it to the SimpleInjector root namespace. (fixes #7)
  • Second argument of Container.Register(Type, Type) renamed from implementation to implementationType.
  • Removed RegisterManyForOpenGeneric extension methods. Either Register or RegisterCollection can be used instead. (fixes #7)
  • Removed OpenGenericBatchRegistrationExtensions.GetTypesToRegister extension methods. Container.GetTypesToRegister can be used instead. (fixes #7)
  • Calling Verify() or GetInstance will always cause the container to check for lifestyle mismatches unless Container.Options.SuppressLifestyleMismatchVerification is set. (fixes #46)
  • Calling Verify() will now standard do diagnostic analysis. Diagnostic analysis can be suppressed by calling the Verify(VerificationOption) overload (but this is highly discouraged). (fixes #10)
  • Class constraint where TService : class added to GetAllInstances<TService>() method.
  • Renamed PotentialLifestyleMismatchDiagnosticResult class to LifestyleMismatchDiagnosticResult. There's nothing 'potential' about that mismatch. We're actually sure that this is a mismatch. (fixes #84)
  • Made UnregisteredTypeEventArgs constructor internal.

Breaking changes for the SimpleInjector.Extensions.LifetimeScoping.dll

  • Removed the LifetimeScope class. Scope can be used instead. (fixes #12)
  • Removed the SimpleInjectorLifetimeScopeExtensions.EnableLifetimeScoping method. The method has been marked obsolete since Simple Injector 2.6. (fixes #12)

Breaking changes for the SimpleInjector.Integration.Wcf.dll

  • Removed the WcfOperationScope class. Scope can be used instead. (fixes #12)
  • Removed the SimpleInjectorWcfExtensions.EnablePerWcfOperationLifestyle method. The method has been marked obsolete since Simple Injector 2.6. (fixes #12)

Breaking changes for the SimpleInjector.Integration.Web.dll

  • Removed the SimpleInjectorWebExtensions.RegisterForDisposal method. WebRequestLifestyle.RegisterForDisposal can be used instead. (fixes #12)

Breaking changes for the SimpleInjector.Integration.Web.Mvc.dll

  • Removed the SimpleInjectorMvcExtensions.RegisterMvcAttributeFilterProvider method. RegisterMvcIntegratedFilterProvider can be used instead. (fixes #12)

Breaking changes for the SimpleInjector.Integration.WebApi.dll

  • Removed the SimpleInjectorWebApiExtensions.RegisterWebApiFilterProvider method. Please consult the Web API integration guide on how to inject dependencies into Web API filter attributes. (fixes #12)

Bug fixes:

  • Registering a Func<object> using UnregisteredTypeEventArgs.Register(Func<object>) caused the Diagnostic system to throw a NullReferenceException. (fixes #49)
  • Prevented incorrectly mixing registrations for several types of collections. (fixes #8)
  • Cyclic dependency in type registered using RegisterOpenGeneric caused a stackoverflow.
  • Huge transient object graphs failed to be compiled and caused the CLR to throw a stackoverflow exception. (fixes #91)