@@ -623,25 +623,32 @@ private SymbolDefinition[] GetExpandedInvokeParams(MethodBase targetMethod, Symb
623623 {
624624 int paramCount = invokeParams . Length - i ;
625625
626- SymbolDefinition paramsArraySymbol = visitorContext . topTable . CreateConstSymbol ( methodParams [ i ] . ParameterType ,
627- System . Activator . CreateInstance ( methodParams [ i ] . ParameterType , new object [ ] { paramCount } ) ) ;
628-
629- for ( int j = i ; j < invokeParams . Length ; ++ j )
626+ if ( paramCount == 1 && methodParams [ i ] . ParameterType . IsImplicitlyAssignableFrom ( invokeParams [ i ] . userCsType ) )
630627 {
631- int paramArrayIndex = j - i ;
632-
633- // This can potentially grow unbounded, but we'll hope that the user doesn't go insane with the param count
634- SymbolDefinition arrayIndexSymbol = visitorContext . topTable . CreateConstSymbol ( typeof ( int ) , paramArrayIndex ) ;
628+ newInvokeParams . Add ( invokeParams [ i ] ) ;
629+ }
630+ else
631+ {
632+ SymbolDefinition paramsArraySymbol = visitorContext . topTable . CreateConstSymbol ( methodParams [ i ] . ParameterType ,
633+ System . Activator . CreateInstance ( methodParams [ i ] . ParameterType , new object [ ] { paramCount } ) ) ;
635634
636- using ( ExpressionCaptureScope paramArraySetterScope = new ExpressionCaptureScope ( visitorContext , null ) )
635+ for ( int j = i ; j < invokeParams . Length ; ++ j )
637636 {
638- paramArraySetterScope . SetToLocalSymbol ( paramsArraySymbol ) ;
639- paramArraySetterScope . HandleArrayIndexerAccess ( arrayIndexSymbol ) ;
640- paramArraySetterScope . ExecuteSet ( invokeParams [ j ] ) ;
637+ int paramArrayIndex = j - i ;
638+
639+ // This can potentially grow unbounded, but we'll hope that the user doesn't go insane with the param count
640+ SymbolDefinition arrayIndexSymbol = visitorContext . topTable . CreateConstSymbol ( typeof ( int ) , paramArrayIndex ) ;
641+
642+ using ( ExpressionCaptureScope paramArraySetterScope = new ExpressionCaptureScope ( visitorContext , null ) )
643+ {
644+ paramArraySetterScope . SetToLocalSymbol ( paramsArraySymbol ) ;
645+ paramArraySetterScope . HandleArrayIndexerAccess ( arrayIndexSymbol ) ;
646+ paramArraySetterScope . ExecuteSet ( invokeParams [ j ] ) ;
647+ }
641648 }
642- }
643649
644- newInvokeParams . Add ( paramsArraySymbol ) ;
650+ newInvokeParams . Add ( paramsArraySymbol ) ;
651+ }
645652 break ;
646653 }
647654
0 commit comments