Implement proper POD types check in C# network replication codegen

This commit is contained in:
Wojtek Figat
2023-06-18 15:33:57 +02:00
parent 1a6e706e57
commit 9e2e6759bd
2 changed files with 19 additions and 3 deletions

View File

@@ -367,8 +367,24 @@ namespace Flax.Build.Plugins
private static bool IsRawPOD(TypeReference type)
{
// TODO:
return type.IsValueType;
if (type.FullName == "System.ValueType")
return true;
if (type.IsValueType)
{
var typeDef = type.Resolve();
if (typeDef.IsEnum)
return true;
var baseType = typeDef.BaseType;
if (baseType != null && !IsRawPOD(baseType))
return false;
foreach (var field in typeDef.Fields)
{
if (!field.IsStatic && field.FieldType != type && !IsRawPOD(field.FieldType))
return false;
}
return true;
}
return false;
}
private void OnGenerateCppTypeSerializeData(Builder.BuildData buildData, ApiTypeInfo caller, StringBuilder contents, TypeInfo type, string name, bool serialize)