NLua / NLua

Bridge between Lua and the .NET.

Home Page:http://nlua.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

problem with same method in class and base class

karsten001 opened this issue · comments

My last issue with a similar problem has been fixed so fast, thank you very much for doing this. I found another issue. If the base class has the same method with different parameters lua always tries to match the method to the main class and so you will get an error that the parameter does not match.

C# classes

public class parameter
{
    string param1;
    string param2;
}

public class master
{
    public static string read( parameter test )
    {
        return "test";
    }
}


public class testClass : master 
{
    public String strData;
    public int intData;
    public static string read( int test )
    {
        return "test";
    }

    public static string read2(int test)
    {
        return "test";
    }
    public static string read2(parameter test)
    {
        return "test";
    }
}

lua code:

luanet.load_assembly 'D_4_0_Prototype.Test'
luanet.import_type 'D_4_0_Prototype.Test.master'
testclass = luanet.import_type 'D_4_0_Prototype.Test.testClass'
parameter = luanet.import_type 'D_4_0_Prototype.Test.parameter'
p=parameter()

result:

testclass.read2(1)   -- is working
testclass.read2(p)   -- is working
testclass.read(p)     -- is not working. it is also not working if the method in base class has two parameters instead of one
testclass.read(1)     -- is working

You will also get another error messages if you first call

testclass.read(1) 

and then

testclass.read(p)

Regards

Karsten