tuyoogame / huatuo

huatuo是一个特性完整、零成本、高性能、低内存的近乎完美的Unity全平台原生c#热更方案。 Huatuo is a fully featured, zero-cost, high-performance, low-memory solution for Unity's all-platform native c# hotfix
MIT License
2.31k stars 377 forks source link

Task<T>的泛型方法调用失败 #32

Closed wumiao1990 closed 2 years ago

wumiao1990 commented 2 years ago

AOT部分

public struct AckMsg<T>
{
    public bool cancel;
    public T msg;

    public AckMsg(T msg, bool cancel)
    {
        this.msg = msg;
        this.cancel = cancel;
    }
}
public class RcvMsgTest
{
    public int id;

}
public static async Task<AckMsg<T>> RefTypeAddTask<T>()
{
    var tcs = new TaskCompletionSource<T>();
    Debug.Log("Send---b");
    var task = tcs.Task;
    await task;
    return new AckMsg<T>((T)tcs.Task.Result, false);
}

热更新部分调用Enter方法,奇怪的是我将Send2函数内容放到Send方法里面就正常

public static async void Enter()
{
    await Send<RcvMsgTest>();
}
public static async Task<AckMsg<T>> Send<T>()
{
    return await Send2<T>();
}

public static async Task<AckMsg<T>> Send2<T>()
{
    var tcs = new TaskCompletionSource<T>();
    var task = tcs.Task;
    await task;
    return new AckMsg<T>((T) tcs.Task.Result, false);
}
wumiao1990 commented 2 years ago

更到最新代码后就好了