Fix IndexOutOfRangeException in AddOptionalParameterToInvocationAction