Simple Injector 2.4 beta1 available

Oct 16, 2013 at 8:32 PM
Edited Oct 16, 2013 at 8:35 PM
We just pushed the first beta release of Simple Injector 2.4 to NuGet. Besides fixing a few bugs, the most important new features in this release are:
  • Work item 20062: There's now an API for querying diagnostic results. The diagnostic API is in the new SimpleInjector.Diagnostics.dll that is included in the core package.
  • Work item 19969: A new abstract ScopedLifestyle class is added to the core library. WebRequestLifestyle, LifetimeScopeLifestyle, and WcfOperationLifestyle implement this lifestyle. The ScopedLifestyle class defines a WhenScopeEnds and a RegisterForDisposal method. The abstraction makes it easier to extract all shared registrations (i.e. registration code that is used by multiple applications within the same solution) without the abstracted code to have to deal with the actual scoped implementation, since scoped lifestyles are often dependent on the actual application.
  • Work item 19992: Registered collections can now be injected and resolved as IReadOnlyCollection<T> and IReadOnlyList<T> (.NET 4.5 only).
  • Work item 20284: New RegisterOpenGeneric overloads have been added that allow passing on a predicate that allows determining on a per-type basis whether the registered implementation should be applied.
Note on the quality of this beta release: This beta is of super high quality and can be used in production, but please understand new features could be changed based on any feedback.

There's one particular feature that we're very interested in getting feedback on and that's the new Diagnostics API. Please try it out and let us know!

The Diagnostic API is especially useful unit testing. You can now query the container's configuration for validation warnings and act accordingly. Here's an example:
// include the SimpleInjector.Diagnostics.dll
using SimpleInjector;
using SimpleInjector.Diagnostics;

public void Container_Configuration_Should_Result_No_Diagnostic_Warnings()
    // Arrange
    Container container = Bootstrapper.CreateContainer();

    // Act

    // Assert
    IEnumerable<DiagnosticResult> results =
        from result in Analyzer.Analyze(container)
        where result.DiagnosticType != DiagnosticType.ContainerRegisteredService
        select result;

    Assert.AreEqual(0, results.Count(), 
        "The following errors where reported:\n" +
        string.Join("\n-", results.Select((r => r.Description))));
Marked as answer by dot_NET_Junkie on 2/26/2014 at 1:18 PM