2.0.0
Autofac has been updated to version 6.0.0
Breaking changes
We have used a new Autofac 6.0.0
API, which allows registering an open generic associated with a delegate/lambda expression.
The signatures of the new Autofac's method and the method that registers factories for non-generic types are different. Therefore, we also had to distinguish between signatures for open generic types and non-open generic types.
Before
// Registering a mapping of a non-open generic interface
containerBuilder.RegisterLazy(typeof(IFoo), typeof(Foo));
// Registering a mapping of an open generic interface
containerBuilder.RegisterLazy(typeof(IFoo<>), typeof(Foo<>));
After
// Registering a mapping of a non-open generic interface
containerBuilder.RegisterLazy(typeof(IFoo), typeof(Foo));
// Registering a mapping of an open generic interface
containerBuilder.RegisterGenericLazy(typeof(IFoo<>), typeof(Foo<>));
We also added a check at runtime for the type. If the wrong type is used, an ArgumentException
will be thrown, just like Autofac does.
// ArgumentException when registering a mapping of a non-open generic interface using the wrong method
containerBuilder.RegisterGenericLazy(typeof(IFoo), typeof(Foo));
// ArgumentException when registering a mapping of an open generic interface using the wrong method
containerBuilder.RegisterLazy(typeof(IFoo<>), typeof(Foo<>));