-
-
Notifications
You must be signed in to change notification settings - Fork 840
KeyFilterAttribute behavior different from AutowiringParameter #1030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Sounds like a bug! Nice find, thanks for the analysis. |
Fixing this issue will be a breaking change. Additionally, to fix this bug, I think we will need to change the To limit the breaking changes, a new class " What is the best approach to solve this? |
We have a 5.0 in the works that changes containers to be immutable and changes several other method signatures. If something has to break to fix this, this would be the time. |
@tillig, What is the branch for this new version? Is it pr-immutable-container? |
Go ahead and target |
When there the parameter type is not registered in the DI, the
KeyFilterAttribute
behavior is different from theAutowiringParameter
behavior.Examples
"Normal" required parameter
Output
Throws:
"Normal" optional parameter
Output
Prints:
Required parameter with
KeyFilter
Output
Prints:
Expected Output?
Throws:
Optional parameter with
KeyFilter
Output
Prints:
Expected Output?
Prints:
Detailed analysis
The
AutowiringParameter
checks whether the parameter type is registered or not. If not, the theAutowiringParameter
returnsfalse
in theCanSupplyValue
method.The
WithAttributeFiltering
method will allows returntrue
in theCanSupplyValue
if aParameterFilterAttribute
is found.Here is a table summarizing the returned value of
Parameter.CanSupplyValue
method:AutowiringParameter
KeyFilterAttribute
Question
Is it the expected behavior?
If so, why is it preferred over consistency with "standard" parameters?
The text was updated successfully, but these errors were encountered: