使用最新版本的(此时最新)的ulua, 生成wrapper文件时,对范型支持支持不是很好,如:
{System.Collections.Generic.List`1[System.String]&} 的type类型,会生成出System.Collections.Generic.List`1[System.String]到c#中,导致编译不通过。
经过代码review, 发现ToLuaExport文件中的GetStrType,对上面的类型判断IsGenericType返回false, 不确定是否是什么原因(&)引起的,
所以在else中修改成如下代码,就可以生成List<String>
else if(t.IsGenericType)
{
return GetGenericName(t);
}
else
{
// modified by cpeng for il2cpp
// referenced to BindLua::GetGenericName
<span style="font-family: Menlo;"> Debug.Log("IsGenericType not work for " + t.ToString());</span>
// t.IsGenericType for {System.Collections.Generic.List`1[System.String]&} somehow return false, we handle it here.
if (t.GetGenericArguments().Length != 0) {
Type[] gArgs = t.GetGenericArguments();
string typeName = t.Name;
string pureTypeName = typeName.Substring(0, typeName.IndexOf('`'));
return pureTypeName + "<" + string.Join(",", GetGenericName(gArgs)) + ">";
}
return _C(t.ToString());
}