@@ -51,33 +51,30 @@ public static object CreateInstance(IServiceProvider provider, Type instanceType
51
51
{
52
52
foreach ( var constructor in instanceType . GetConstructors ( ) )
53
53
{
54
- if ( ! constructor . IsStatic )
55
- {
56
- var matcher = new ConstructorMatcher ( constructor ) ;
57
- var isPreferred = constructor . IsDefined ( typeof ( ActivatorUtilitiesConstructorAttribute ) , false ) ;
58
- var length = matcher . Match ( parameters ) ;
54
+ var matcher = new ConstructorMatcher ( constructor ) ;
55
+ var isPreferred = constructor . IsDefined ( typeof ( ActivatorUtilitiesConstructorAttribute ) , false ) ;
56
+ var length = matcher . Match ( parameters ) ;
59
57
60
- if ( isPreferred )
58
+ if ( isPreferred )
59
+ {
60
+ if ( seenPreferred )
61
61
{
62
- if ( seenPreferred )
63
- {
64
- ThrowMultipleCtorsMarkedWithAttributeException ( ) ;
65
- }
66
-
67
- if ( length == - 1 )
68
- {
69
- ThrowMarkedCtorDoesNotTakeAllProvidedArguments ( ) ;
70
- }
62
+ ThrowMultipleCtorsMarkedWithAttributeException ( ) ;
71
63
}
72
64
73
- if ( isPreferred || bestLength < length )
65
+ if ( length == - 1 )
74
66
{
75
- bestLength = length ;
76
- bestMatcher = matcher ;
67
+ ThrowMarkedCtorDoesNotTakeAllProvidedArguments ( ) ;
77
68
}
69
+ }
78
70
79
- seenPreferred |= isPreferred ;
71
+ if ( isPreferred || bestLength < length )
72
+ {
73
+ bestLength = length ;
74
+ bestMatcher = matcher ;
80
75
}
76
+
77
+ seenPreferred |= isPreferred ;
81
78
}
82
79
}
83
80
@@ -237,11 +234,6 @@ private static bool TryFindMatchingConstructor(
237
234
{
238
235
foreach ( var constructor in instanceType . GetConstructors ( ) )
239
236
{
240
- if ( constructor . IsStatic )
241
- {
242
- continue ;
243
- }
244
-
245
237
if ( TryCreateParameterMap ( constructor . GetParameters ( ) , argumentTypes , out int ? [ ] tempParameterMap ) )
246
238
{
247
239
if ( matchingConstructor != null )
@@ -267,11 +259,6 @@ private static bool TryFindPreferredConstructor(
267
259
var seenPreferred = false ;
268
260
foreach ( var constructor in instanceType . GetConstructors ( ) )
269
261
{
270
- if ( constructor . IsStatic )
271
- {
272
- continue ;
273
- }
274
-
275
262
if ( constructor . IsDefined ( typeof ( ActivatorUtilitiesConstructorAttribute ) , false ) )
276
263
{
277
264
if ( seenPreferred )
0 commit comments