-
-
Notifications
You must be signed in to change notification settings - Fork 837
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
Func<T,U,...> should not be resolvable if any parameter types are duplicated #269
Comments
From [email protected] on October 22, 2010 22:55:29 Thanks for the report - I think failing is the appropriate thing to do here, ordering doesn't make a lot of sense in loosely-coupled scenarios. To make your scenario work, declare and resolve a custom delegate type - for custom delegates, parameters are matched by name rather than by type. Regards, Summary: Func<T,U,...> should not be resolvable if any parameter types are duplicated |
From [email protected] on October 25, 2010 10:40:24 That works... Awesome! Thanks! |
From [email protected] on June 19, 2011 10:18:53 To throw in my 2 cents... We ran into this too and it was rather frustrating. The instinct of everyone was that this scenario should work, and it took us quite a bit of debugging before we just tried registering a custom delegate. As a result, we have over 10 delegates registered this way, and it's rather annoying. |
From travis.illig on September 21, 2012 09:29:31 Labels: Module-Core |
From travis.illig on May 13, 2013 18:00:05 Issue 429 has been merged into this issue. |
From travis.illig on December 17, 2013 12:12:28 I have a solution working where:
I didn't have the DependencyResolutionException thrown until the Resolve call happens so you can register an override. Throwing too early made it so you couldn't do that. The only potentially weird thing is that if you have duplicate types in the constructor of your object but not in the requested generated Func, you'll get odd behavior. For example... public class DuplicateParams var func = container.Resolve<Func<int, string>>(); When you do that, the function WILL resolve the class, it'll just pass the same value in for the integer type parameter. So... func(1, "2") is the same as calling new DuplicateParams(1, 1, "2") That is the default behavior for Autofac, though, so I thought that was OK. I'll write a few more tests up for this and commit it. Status: Started |
From travis.illig on December 17, 2013 12:30:36 This issue was closed by revision b23f07398a4d . Status: Fixed |
From [email protected] on October 23, 2010 06:55:43
What steps will reproduce the problem? 1. Have a class you want to inject that has a constructor with three or more parameters, at least two having the same type. For example: public InjectMe(string sJuan, int iJuan, string sToo, int iToo){}
what I see instead is the constructor of InjectMe gets "hello" for sJuan AND sToo... and 11 for iJuan AND iToo. What version of the product are you using? On what operating system? 2.2.4.900. Windows 7 Please provide any additional information below. I love the Func<> feature!
Original issue: http://code.google.com/p/autofac/issues/detail?id=269
The text was updated successfully, but these errors were encountered: