autofac / Autofac

An addictive .NET IoC container
https://autofac.org
MIT License
4.44k stars 836 forks source link

Ignore required properties in the default autowiring property selector. #1369

Closed alistairjevans closed 1 year ago

alistairjevans commented 1 year ago

Noticed during the docs creation for required properties, before this change any registrations with PropertiesAutowired applied would duplicate property injection with required properties.

I decided to just blanket ignore required properties in the DefaultPropertySelector. My logic for this was as follows:

If someone inside a lambda uses Activator.CreateInstance directly (for some reason) to bypass the required properties, those required properties won't be injected; but then, why aren't you using the reflection activator?

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.04 :tada:

Comparison is base (3489ad3) 78.49% compared to head (6f335e7) 78.53%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #1369 +/- ## =========================================== + Coverage 78.49% 78.53% +0.04% =========================================== Files 199 199 Lines 5715 5717 +2 Branches 1161 1162 +1 =========================================== + Hits 4486 4490 +4 + Misses 716 715 -1 + Partials 513 512 -1 ``` | [Impacted Files](https://codecov.io/gh/autofac/Autofac/pull/1369?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=autofac) | Coverage Δ | | |---|---|---| | [...Autofac/Core/Activators/DefaultPropertySelector.cs](https://codecov.io/gh/autofac/Autofac/pull/1369?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=autofac#diff-c3JjL0F1dG9mYWMvQ29yZS9BY3RpdmF0b3JzL0RlZmF1bHRQcm9wZXJ0eVNlbGVjdG9yLmNz) | `81.25% <100.00%> (+2.67%)` | :arrow_up: | | [src/Autofac/Util/SequenceGenerator.cs](https://codecov.io/gh/autofac/Autofac/pull/1369?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=autofac#diff-c3JjL0F1dG9mYWMvVXRpbC9TZXF1ZW5jZUdlbmVyYXRvci5jcw==) | `100.00% <0.00%> (+28.57%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=autofac). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=autofac)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.