xLua
xLua copied to clipboard
unity 2021.2 之后版本生成代码异常
unity在2021.2之后使用了C#9,Api Compatibility Level 已经没有了.Net4.x,只能选择.Net Framework。在这个版本下生成代码会出现错误。跪求兼容
error CS0306: The type 'Span<byte>' may not be used as a type argument
我们这边加一句这个暂时规避了一下,等官方修复吧
@Jidayong 谢谢
TimeSpan和DateTime类的生成代码也报类似的错
能提供下完整的代码吗?🙏
Unity2021.3.21f1 生成报错


@Jidayong 加的那一行后还会有


目前加入黑名单列表把报错的函数
public static List<Type> BlackGenericTypeList = new List<Type>()
{
typeof(Span<>),
typeof(ReadOnlySpan<>),
};
private static bool IsBlacklistedGenericType(Type type)
{
if (!type.IsGenericType) return false;
return BlackGenericTypeList.Contains(type.GetGenericTypeDefinition());
}
[BlackList] public static Func<MemberInfo, bool> GenericTypeFilter = (memberInfo) =>
{
switch (memberInfo)
{
case PropertyInfo propertyInfo:
return IsBlacklistedGenericType(propertyInfo.PropertyType);
case ConstructorInfo constructorInfo:
return constructorInfo.GetParameters().Any(p => IsBlacklistedGenericType(p.ParameterType));
case MethodInfo methodInfo:
return methodInfo.GetParameters().Any(p => IsBlacklistedGenericType(p.ParameterType));
default:
return false;
}
};