-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
ActivatorUtilities: Do not wrap Delegate.Invoke in another delegate #105814
Conversation
Tagging subscribers to this area: @dotnet/area-extensions-dependencyinjection |
Thanks huoyaoyuan but I'm going to mark this "No Merge" until the This doesn't meet the bar to get it into v9.0. |
factoryExpressionBody, provider, argumentArray); | ||
|
||
Func<IServiceProvider, object?[]?, object>? result = factoryLambda.Compile(); | ||
return result.Invoke; | ||
ObjectFactory? result = factoryLambda.Compile(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for other reviewers: ObjectFactory delegate is declared here:
runtime/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ObjectFactory.cs
Line 14 in da757a1
public delegate object ObjectFactory(IServiceProvider serviceProvider, object?[]? arguments); |
@@ -324,11 +324,11 @@ public static ObjectFactory<T> | |||
#endif | |||
CreateFactoryInternal(typeof(T), argumentTypes, out ParameterExpression provider, out ParameterExpression argumentArray, out Expression factoryExpressionBody); | |||
|
|||
var factoryLambda = Expression.Lambda<Func<IServiceProvider, object?[]?, T>>( | |||
var factoryLambda = Expression.Lambda<ObjectFactory<T>>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for other reviewers: ObjectFactory<T>
delegate is declared here
#104731 (comment)
There's no conversion between delegates with same signature. Using Invoke method for another type will create another level of indirection.
Here the delegates can be created directly into ObjectFactory type.