1
Vote

overloaded methods with optional parameters

description

Hi,

I think this issue is available since the start of the original project.
If you have a class with overloaded methods which have also optional parameters like:
public class OverLoadedOptionalParameters
{
    public static int Sum(int a, int b, params int[] optional)
    {
        int sum = 0;
        foreach (int element in optional)
            sum += element;

        return sum + a + b;
    }

    public static int Sum(int a, params int[] optional)
    {
        int sum = 0;
        foreach (int element in optional)
            sum += element;

        return sum + a;
    }
}
If you import that class into the eval context, any evaluation of an expression like Sum(1) will lead to an unhandled exception in method

IsParamArrayMatch

of file

InternalTypes/Miscellaneous.cs at line

System.Array.Copy(argTypes, fixedArgTypes, fixedParameterCount);

To fix it just insert the following line before

if (fixedParameterCount > argTypes.Length) return false;

Thank for porting this great library to c#
Best regards

comments