Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ public static ObjectFactory CreateFactory(
#endif
CreateFactoryInternal(instanceType, argumentTypes, out ParameterExpression provider, out ParameterExpression argumentArray, out Expression factoryExpressionBody);

var factoryLambda = Expression.Lambda<Func<IServiceProvider, object?[]?, object>>(
var factoryLambda = Expression.Lambda<ObjectFactory>(
factoryExpressionBody, provider, argumentArray);

Func<IServiceProvider, object?[]?, object>? result = factoryLambda.Compile();
return result.Invoke;
ObjectFactory? result = factoryLambda.Compile();
Copy link
Contributor

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:

public delegate object ObjectFactory(IServiceProvider serviceProvider, object?[]? arguments);

return result;
}

/// <summary>
Expand Down Expand Up @@ -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>>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

factoryExpressionBody, provider, argumentArray);

Func<IServiceProvider, object?[]?, T>? result = factoryLambda.Compile();
return result.Invoke;
ObjectFactory<T>? result = factoryLambda.Compile();
return result;
}

private static void CreateFactoryInternal([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type instanceType, Type[] argumentTypes, out ParameterExpression provider, out ParameterExpression argumentArray, out Expression factoryExpressionBody)
Expand Down