rdotnet/rClr

Can't call overloaded methods that have enum parameters

1tgr opened this issue · 0 comments

1tgr commented

(See also Stack Overflow: https://stackoverflow.com/q/44702930/32133)

For a non-overloaded method, passing an integer works where an enum is expected. When calling an overloaded method, this integer doesn't seem to be enough to push overload resolution in the right direction.

In R:

library(rClr)
clrLoadAssembly('Temp.dll')

# Error in clrNew("Temp.MyClass", as.integer(0)): Type:    System.MissingMethodException
# Message: Constructor on type 'Temp.MyClass' not found.
clrNew('Temp.MyClass', as.integer(0))

# Works
clrNew('Temp.MyClass', 'hello')

And the corresponding C#:

namespace Temp
{
    public enum MyEnum
    {
        First,
        Second
    }

    public class MyClass
    {
        public MyClass(string thing)
        {
        }

        public MyClass(MyEnum thing)
        {
        }
    }
}