Skip to content

v2.1.0 - Autofac Conventions Package

Compare
Choose a tag to compare
@JakeGinnivan JakeGinnivan released this 28 Sep 17:16
· 98 commits to master since this release

This is a minor release which introduces a new package TestStack.ConventionTests.Autofac

Which contains two conventions

CanResolveAllRegisteredServices

Tries to resolve all services from your container, failing if it cannot resolve a service. You currently cannot override parameters, so if you are using automatic factories with parameters (Func<,>) this will not work

ServicesShouldOnlyHaveDependenciesWithLesserLifetime

Generally, if you have a SingleInstance which has a Transient or PerLifetimeScope service injected this is a misconfiguration, or a refactoring gone bad.

This convention will enforce that this does not happen. For Example

'Components should not depend on with greater lifetimes' for 'Autofac registrations in All AutofacContainer Registrations'
--------------------------------------------------------------------------------------------------------------------------

    TestStack.ConventionTests.Tests.Autofac.TestTypes.Foo (SingleInstance) => TestStack.ConventionTests.Tests.Autofac.TestTypes.IBar (Transient)