Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在扩展方法函数参数Action回调中,传入扩展方法,导致程序直接崩溃 #16

Closed
blueberryWT opened this issue Apr 4, 2022 · 2 comments

Comments

@blueberryWT
Copy link

No description provided.

@blueberryWT
Copy link
Author

测试环境

Untiy 2017.3.7f1c1,PC,IL2CPP, NET4.x‘

测试代码

public static class PersonSystem
{
    public static void Foo(this Person _self)
    {
        _self.SetCallback(_self.OnCallbackEvent); // 这里只有传入扩展方法才会crash,匿名函数,delegate,静态方法均没问题
    }

    private static void OnCallbackEvent(this Person _self)
    {
        Debug.Log("call back event.");
    }

    public static void SetCallback(this Person _self, Action _callback)
    {
        _callback?.Invoke();
    }
}

预期结果

能够正常执行到OnCallbackEvent方法,并打印 "call back event"

代码文件

code_case.zip

@pirunxi
Copy link
Contributor

pirunxi commented Apr 5, 2022

确认。已修复。稍后提交。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants