|
|
@@ -51,33 +51,30 @@ namespace Microsoft.Extensions.Internal
|
|
|
{
|
|
|
foreach (var constructor in instanceType.GetConstructors())
|
|
|
{
|
|
|
- if (!constructor.IsStatic)
|
|
|
- {
|
|
|
- var matcher = new ConstructorMatcher(constructor);
|
|
|
- var isPreferred = constructor.IsDefined(typeof(ActivatorUtilitiesConstructorAttribute), false);
|
|
|
- var length = matcher.Match(parameters);
|
|
|
+ var matcher = new ConstructorMatcher(constructor);
|
|
|
+ var isPreferred = constructor.IsDefined(typeof(ActivatorUtilitiesConstructorAttribute), false);
|
|
|
+ var length = matcher.Match(parameters);
|
|
|
|
|
|
- if (isPreferred)
|
|
|
+ if (isPreferred)
|
|
|
+ {
|
|
|
+ if (seenPreferred)
|
|
|
{
|
|
|
- if (seenPreferred)
|
|
|
- {
|
|
|
- ThrowMultipleCtorsMarkedWithAttributeException();
|
|
|
- }
|
|
|
-
|
|
|
- if (length == -1)
|
|
|
- {
|
|
|
- ThrowMarkedCtorDoesNotTakeAllProvidedArguments();
|
|
|
- }
|
|
|
+ ThrowMultipleCtorsMarkedWithAttributeException();
|
|
|
}
|
|
|
|
|
|
- if (isPreferred || bestLength < length)
|
|
|
+ if (length == -1)
|
|
|
{
|
|
|
- bestLength = length;
|
|
|
- bestMatcher = matcher;
|
|
|
+ ThrowMarkedCtorDoesNotTakeAllProvidedArguments();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- seenPreferred |= isPreferred;
|
|
|
+ if (isPreferred || bestLength < length)
|
|
|
+ {
|
|
|
+ bestLength = length;
|
|
|
+ bestMatcher = matcher;
|
|
|
}
|
|
|
+
|
|
|
+ seenPreferred |= isPreferred;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -237,11 +234,6 @@ namespace Microsoft.Extensions.Internal
|
|
|
{
|
|
|
foreach (var constructor in instanceType.GetConstructors())
|
|
|
{
|
|
|
- if (constructor.IsStatic)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
if (TryCreateParameterMap(constructor.GetParameters(), argumentTypes, out int?[] tempParameterMap))
|
|
|
{
|
|
|
if (matchingConstructor != null)
|
|
|
@@ -267,11 +259,6 @@ namespace Microsoft.Extensions.Internal
|
|
|
var seenPreferred = false;
|
|
|
foreach (var constructor in instanceType.GetConstructors())
|
|
|
{
|
|
|
- if (constructor.IsStatic)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
if (constructor.IsDefined(typeof(ActivatorUtilitiesConstructorAttribute), false))
|
|
|
{
|
|
|
if (seenPreferred)
|