aspnet/DependencyInjection

Turn on scope validation by default

danroth27 opened this issue · 7 comments

For 2.0 we should consider turning on scope validation by default.

@pakrym before we turn this on by default need to look at the performance impact.

Here's results from a benchmark I've added.

                       Method |        Mean |    StdErr |     StdDev |        Op/s | Scaled | Scaled-StdDev |  Gen 0 | Allocated |
----------------------------- |------------ |---------- |----------- |------------ |------- |-------------- |------- |---------- |
                    Transient |  43.5473 ns | 0.4130 ns |  2.2620 ns | 22963524.25 |   1.00 |          0.00 | 0.0095 |      24 B |
 TransientWithScopeValidation |  68.7545 ns | 1.3960 ns |  7.6460 ns | 14544498.22 |   1.58 |          0.19 | 0.0076 |      24 B |

@danroth27 @DamianEdwards @Eilon do we want this on by default? Currently they can turn this on with a single line in program main.

If we want to turn this on by default, we'll need to do it across our tests firsts.

We were looking at this in DI triage with @davidfowl and @pakrym and we're not sure if this should be done.

It would be really nice if this was on by default, but we would need to test the perf impact.

Perhaps we should just update the templates to have it on by default for Development only?

@DamianEdwards that sounds reasonable to me. And we would also enable it at least for a portion of the tests, right?