Is it possible to easily configure autofac so it will only resolve using non-obsolete constructors?
eg for a class with a helper constructor for non-DI code,
public class Example {
public Example(MyService service) {
// ...
}
[Obsolete]
public Example() {
service = GetFromServiceLocator<MyService>();
// ...
}
}
// ....
var builder = new ContainerBuilder();
builder.RegisterType<Example>();
// no MyService defined.
var container = builder.Build();
// this should throw an exception
var example = container.Resolve<Example>();
asking autofac to resolve Example if we haven't registered MyService, should fail.