forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify
CreateInstance
and CreateFactory
Previously `ActivatorUtilities.CreateInstance` and `ActivatorUtilities.CreateFactory` behaved differently: former depended on ctor definition order to disambiguate ctors, while latter failed altogether. The behavior is now unified and addresses concerns raised in dotnet#45119 dotnet#42339 and dotnet#46132. Constructors are chosen based on the following factors in a given order: 1) Preferred ctor (having [ActivatorUtilitiesConstructor] attribute) 2) Ctor with the most surjective parameters based on the given arguments. In other words constructor that has the least unresolved parameters is chosen. 3) Ctor with more resolved parameters is prefered. If two ctors have all of the supplied arguments, but one of them has additional parameters with default values, then the one with more parameters is chosen.
- Loading branch information
1 parent
7479663
commit 6fb0b30
Showing
2 changed files
with
94 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters