-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-Extensions-DependencyInjectionbreaking-changeIssue or PR that represents a breaking API or functional change over a prerelease.Issue or PR that represents a breaking API or functional change over a prerelease.bughelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
Milestone
Description
This will throw NullReferenceException, but should throw ArgumentNullException:
var f = Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateFactory(typeof(FOO), new Type[] { });
f(serviceProvider: null, arguments: null);
public class FOO {
public FOO(int i) { }
}See also the breaking change for CreateInstance now throwing ArgumentNullException at dotnet/docs#34158 which should be extended to mention CreateFactory. That PR added the test for a null provider for the non-factory approach but the PR did not change the factory approach or add any tests. The factory approach has more complexity since it requires an Expression to do the check and throw.
Thus, currently, the factory approach and non-factory approach have different semantics for validating against serviceProvier.
Metadata
Metadata
Assignees
Labels
area-Extensions-DependencyInjectionbreaking-changeIssue or PR that represents a breaking API or functional change over a prerelease.Issue or PR that represents a breaking API or functional change over a prerelease.bughelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors