@@ -4097,8 +4097,7 @@ public override object InvokeMember(
40974097 if ( results != null )
40984098 {
40994099 Debug . Assert ( results . Count > 1 ) ;
4100- finalists = new MethodInfo [ results . Count ] ;
4101- results . CopyTo ( finalists ) ;
4100+ finalists = results . ToArray ( ) ;
41024101 }
41034102 }
41044103
@@ -4149,8 +4148,7 @@ public override object InvokeMember(
41494148 if ( results != null )
41504149 {
41514150 Debug . Assert ( results . Count > 1 ) ;
4152- finalists = new MethodInfo [ results . Count ] ;
4153- results . CopyTo ( finalists ) ;
4151+ finalists = results . ToArray ( ) ;
41544152 }
41554153 }
41564154
@@ -4342,8 +4340,6 @@ internal object CreateInstanceImpl(
43424340 if ( args == null )
43434341 args = Array . Empty < object > ( ) ;
43444342
4345- int argCnt = args . Length ;
4346-
43474343 // Without a binder we need to do use the default binder...
43484344 if ( binder == null )
43494345 binder = DefaultBinder ;
@@ -4352,7 +4348,7 @@ internal object CreateInstanceImpl(
43524348 // so a call to GetMemberCons would fail
43534349 bool publicOnly = ( bindingAttr & BindingFlags . NonPublic ) == 0 ;
43544350 bool wrapExceptions = ( bindingAttr & BindingFlags . DoNotWrapExceptions ) == 0 ;
4355- if ( argCnt == 0 && ( bindingAttr & BindingFlags . Public ) != 0 && ( bindingAttr & BindingFlags . Instance ) != 0
4351+ if ( args . Length == 0 && ( bindingAttr & BindingFlags . Public ) != 0 && ( bindingAttr & BindingFlags . Instance ) != 0
43564352 && ( IsGenericCOMObjectImpl ( ) || IsValueType ) )
43574353 {
43584354 server = CreateInstanceDefaultCtor ( publicOnly , false , true , wrapExceptions ) ;
@@ -4363,8 +4359,8 @@ internal object CreateInstanceImpl(
43634359 List < MethodBase > matches = new List < MethodBase > ( candidates . Length ) ;
43644360
43654361 // We cannot use Type.GetTypeArray here because some of the args might be null
4366- Type [ ] argsType = new Type [ argCnt ] ;
4367- for ( int i = 0 ; i < argCnt ; i ++ )
4362+ Type [ ] argsType = new Type [ args . Length ] ;
4363+ for ( int i = 0 ; i < args . Length ; i ++ )
43684364 {
43694365 if ( args [ i ] != null )
43704366 {
@@ -4378,16 +4374,13 @@ internal object CreateInstanceImpl(
43784374 matches . Add ( candidates [ i ] ) ;
43794375 }
43804376
4381- MethodBase [ ] cons = new MethodBase [ matches . Count ] ;
4382- matches . CopyTo ( cons ) ;
4383- if ( cons != null && cons . Length == 0 )
4384- cons = null ;
4385-
4386- if ( cons == null )
4377+ if ( matches . Count == 0 )
43874378 {
43884379 throw new MissingMethodException ( SR . Format ( SR . MissingConstructor_Name , FullName ) ) ;
43894380 }
43904381
4382+ MethodBase [ ] cons = matches . ToArray ( ) ;
4383+
43914384 MethodBase invokeMethod ;
43924385 object state = null ;
43934386
0 commit comments