private bool IsValidCall(string[] argNames, object[] defaultVals) { for (int i = 0; i < argNames.Length; i++) { if (!_haveArg[i]) { if (defaultVals != null && i < defaultVals.Length && defaultVals[i] != DBNull.Value) { _realArgs[i] = defaultVals[i]; _haveArg[i] = true; } else { int realDefaultsCount = 0; for (int d = 0; d < GetNormalArgumentsCount(); d++) { if (defaultVals[d] != DBNull.Value) { realDefaultsCount++; } } _error = RuntimeHelpers.TypeErrorForIncorrectArgumentCount(_methodName, GetNormalArgumentsCount(), realDefaultsCount, _arguments.Length - _kwNames.Length, _paramArrayIndex != -1, true); return(false); } } } return(true); }
private Exception BadArgumentCount(CallType callType, int argCount) { if (_targetSets.Count == 0) { return(new ArgumentTypeException("no callable targets, if this is a generic method make sure to specify the type parameters")); } int minArgs, maxArgs; GetMinAndMaxArgs(out minArgs, out maxArgs); if (callType == CallType.ImplicitInstance) { argCount -= 1; if (maxArgs > 0) { minArgs -= 1; maxArgs -= 1; } } // This generates Python style error messages assuming that all arg counts in between min and max are allowed //It's possible that discontinuous sets of arg counts will produce a weird error message return(RuntimeHelpers.TypeErrorForIncorrectArgumentCount(_name, maxArgs, maxArgs - minArgs, argCount)); }