We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
2.1.1(Master Clone)
6000.0.37f1
Editor(mac)
Struct类型执行完Fillter后,用构造函数创建对象,构造函数功能失效,无法赋值。
重现方法:
1、添加Filter方法,使变量可以正常绑定,其他方法隐藏。
[Filter] static Puerts.BindingMode FilterMethods(System.Reflection.MemberInfo memberInfo) { if (memberInfo.DeclaringType == typeof(PuertsTest.TestStructFilter) || memberInfo.DeclaringType == typeof(PuertsTest.TestClassFilter)) { if (memberInfo is FieldInfo) { return BindingMode.FastBinding; } return BindingMode.DontBinding; } return BindingMode.FastBinding; }
2、创建TestStructFilter和TestClassFilter,分别有a,b,c三个参数和一个构造函数;执行d.ts生成。 (Struct和Class进行对比) C#的测试类:
public struct TestStructFilter { public int a; public int b; public int c; public TestStructFilter(int a, int b, int c) { this.a = a; this.b = b; this.c = c; } } public class TestClassFilter { public int a; public int b; public int c; public TestClassFilter(int a, int b, int c) { this.a = a; this.b = b; this.c = c; } }
生成d.ts后,结构基本一样
class TestStructFilter extends System.ValueType { protected [__keep_incompatibility]: never; public a : number public b : number public c : number public constructor ($a: number, $b: number, $c: number) public constructor () } class TestClassFilter extends System.Object { protected [__keep_incompatibility]: never; public a : number public b : number public c : number public constructor ($a: number, $b: number, $c: number) public constructor () }
3、执行测试代码,发现Class可以正常创建;Struct创建失败,无法获取值。
const testStruct_1 = new CS.PuertsTest.TestStructFilter(100,200,300) console.log("testStruct_1="+testStruct_1.a + " " + testStruct_1.b + " " + testStruct_1.c) //打印testStruct_1的a、b、c为0,Struct创建失败。 const testClass_1 = new CS.PuertsTest.TestClassFilter(900,800,700) console.log("testClass_1="+testClass_1.a + " " + testClass_1.b + " " + testClass_1.c) //打印testClass_1的a、b、c为正常值,Class正常创建。
The text was updated successfully, but these errors were encountered:
chexiongsheng
No branches or pull requests
前置阅读 | Pre-reading
Puer的版本 | Puer Version
2.1.1(Master Clone)
Unity的版本 | Unity Version
6000.0.37f1
发生在哪个平台 | Platform
Editor(mac)
错误信息 | Error Message
Struct类型执行完Fillter后,用构造函数创建对象,构造函数功能失效,无法赋值。
问题重现 | Bug reproduce
重现方法:
1、添加Filter方法,使变量可以正常绑定,其他方法隐藏。
2、创建TestStructFilter和TestClassFilter,分别有a,b,c三个参数和一个构造函数;执行d.ts生成。
(Struct和Class进行对比)
C#的测试类:
生成d.ts后,结构基本一样
3、执行测试代码,发现Class可以正常创建;Struct创建失败,无法获取值。
The text was updated successfully, but these errors were encountered: