Ourpalm / ILRuntime

Pure C# IL Intepreter Runtime, which is fast and reliable for scripting requirement on enviorments, where jitting isn't possible.
Other
2.98k stars 656 forks source link

热更Dll中子类调用主工程中父类虚函数无响应,可以调用父类的公有非虚函数 #152

Open Catzeromeio opened 6 years ago

Catzeromeio commented 6 years ago
class Father
{
    public void Hello()
    {
        Debug.Log("hello");
    }

    public virtual void Say(string contents)
    {
        Debug.Log(contents);
    }

    public void Bye()
    {
        Debug.Log("bye");
    }
}

//继承Adapter 省略

//热更DLL
class Child : Father
{
    public override void Say(string contents)
    {
        Debug.Log("child is speaking: ");
        base.Hello();
        base.Say(contents);
        Debug.Log("speaking is over");
    }
}

var child = appDomain.Instantiate<Father>(name); child.Say("awesome");

输出仅为: child is speaking: hello speaking is over

liiir1985 commented 6 years ago

这得看你Adapter的override Say怎么写的,得看是否调了base.Say

Catzeromeio commented 6 years ago

没有调用,但是应该在Adalpter的override Say的什么位置调用呢?

liiir1985 commented 6 years ago

这个你可以参考ILRuntime的Demo,里面有virtual 函数的正确处理方式