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

[Unity] 1.3.6的一些生成代码问题 #937

Closed
bluedoom opened this issue Jul 27, 2022 · 3 comments
Closed

[Unity] 1.3.6的一些生成代码问题 #937

bluedoom opened this issue Jul 27, 2022 · 3 comments
Assignees

Comments

@bluedoom
Copy link
Contributor

bluedoom commented Jul 27, 2022

  • 带约束的泛型类问生成有问题
    3f17b47
    这里有点奇怪,基类的Wrapper被我强制改了,但是没有生效,子类仍然返回了正确值
////////////////// Puerts_UnitTest_GenericWrapperBase_1_T__Wrap
        [Puerts.MonoPInvokeCallback(typeof(Puerts.V8FunctionCallback))]
        private static void F_GetGenericType(IntPtr isolate, IntPtr info, IntPtr self, int paramLen, long data)
        {
            try
            {
                        //这里没有使用T,而是强制给了一个值
                        var result = Puerts.UnitTest.GenericWrapperBase<Version>.GetGenericType();
                        Puerts.ResultHelper.Set((int)data, isolate, info, result);
            }
            catch (Exception e)
            {
                Puerts.PuertsDLL.ThrowException(isolate, "c# exception:" + e.Message + ",stack:" + e.StackTrace);
            }
        }
////////////////// UT
       [Test]
        public void GenericTest3()
        {
            var jsEnv = new JsEnv(new TxtLoader());
            PuertsStaticWrap.AutoStaticCodeRegister.Register(jsEnv);
            Type secondGenericType = jsEnv.Eval<Type>(@"
                const CS = require('csharp');
                CS.Puerts.UnitTest.GenericGenTest2.GetGenericType();
            ");

            Type mustBeVersion = jsEnv.Eval<Type>(@"
                var gen = puerts.$generic(CS.Puerts.UnitTest.GenericWrapperBase$1, CS.Puerts.UnitTest.GenericGenTest2);
                gen.GetGenericType();
            ");


            jsEnv.Dispose();
            Assert.AreEqual(typeof(Version), mustBeVersion); // 这里会报错,mustBeVersion实际上是 GenericGenTest2

            Assert.AreEqual(typeof(GenericGenTest2), secondGenericType);
        }
  • 另外就是有一些生成报错,可以用上面提交重新生成生成代码复现
    image
    image

  • wrapper有点小问题
    adc209b

@bluedoom
Copy link
Contributor Author

旧版本1.2.2是OK的

@zombieyang zombieyang self-assigned this Jul 27, 2022
@zombieyang
Copy link
Contributor

adc209b
这个你其实可以直接PR的。

第一个问题,应该要想办法把检测出来的约束原封不动搬到wrapper上才行

@zombieyang zombieyang added this to the unity-1.4.0-rc.0 milestone Jul 28, 2022
@zombieyang
Copy link
Contributor

1.3.7版本已经默认不打开generic wrapper功能。该功能后续在1.4.0再实装

zombieyang added a commit that referenced this issue Aug 11, 2022
…the constraints filter ignored optional parameters fix #937
zombieyang added a commit to zombieyang/puerts that referenced this issue Aug 12, 2022
…the constraints filter ignored optional parameters fix Tencent#937
@zombieyang zombieyang assigned zombieyang and unassigned zombieyang Aug 14, 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