TLDR;
This issue introduces an Container.Options.ResolveUnregisteredConcreteTypes configuration flag that allows disabling resolving unregistered concrete types:
var container = new Container();
container.Options.ResolveUnregisteredConcreteTypes = false;
This feature was added to Simple Injector v4.5. In Simple Injector v4.x it defaults to true, which is the pre-v4.5 behavior, which means Simple Injector will try to resolve concrete types on your behalf, even in the absence of a registration for that concrete type.
Simple Injector v5.0 will change the default to false. You are, however, advised to change the setting to false directly while working with Simple Injector v4.x. This prevents surprises when migrating to v5.x.
The rest of this issue describes the long discussion about the design and behavior of this feature.
Simple Injector currently resolves unregistered concrete types by default. Although this is convenient in a number of cases, it can also lead to errors. Because of this, Simple Injector has several Diagnostic warnings that shield the user from making errors when using concrete unregistered types, such as:
Some improvements in v4 will even improve the likelihood that configuration mistakes are spotted.
Still, however, it is possible for users to shoot themselves in the foot, for instance by accidentally resolving a concrete type (when doing dispatching for instance) instead of the interface. This would prevent Simple Injector from being able to apply decorators.
Perhaps we should disable the creation of unregistered concrete types by default, to prevent these errors and supply a configuration switch that allows the user to re-enable this behavior, for legacy scenarios:
container.Options.ResolveUnregisteredConcreteTypes = true;
Let's discuss.
TLDR;
This issue introduces an
Container.Options.ResolveUnregisteredConcreteTypesconfiguration flag that allows disabling resolving unregistered concrete types:This feature was added to Simple Injector v4.5. In Simple Injector v4.x it defaults to
true, which is the pre-v4.5 behavior, which means Simple Injector will try to resolve concrete types on your behalf, even in the absence of a registration for that concrete type.Simple Injector v5.0 will change the default to
false. You are, however, advised to change the setting tofalsedirectly while working with Simple Injector v4.x. This prevents surprises when migrating to v5.x.The rest of this issue describes the long discussion about the design and behavior of this feature.
Simple Injector currently resolves unregistered concrete types by default. Although this is convenient in a number of cases, it can also lead to errors. Because of this, Simple Injector has several Diagnostic warnings that shield the user from making errors when using concrete unregistered types, such as:
Some improvements in v4 will even improve the likelihood that configuration mistakes are spotted.
Still, however, it is possible for users to shoot themselves in the foot, for instance by accidentally resolving a concrete type (when doing dispatching for instance) instead of the interface. This would prevent Simple Injector from being able to apply decorators.
Perhaps we should disable the creation of unregistered concrete types by default, to prevent these errors and supply a configuration switch that allows the user to re-enable this behavior, for legacy scenarios:
Let's discuss.