Implement proper POD types check in C# network replication codegen
This commit is contained in:
@@ -32,7 +32,7 @@ namespace Flax.Build.Bindings
|
||||
return;
|
||||
}
|
||||
|
||||
// Structure is POD (plain old data) only if all of it's fields are (and has no base type ro base type is also POD)
|
||||
// Structure is POD (plain old data) only if all of it's fields are (and has no base type or base type is also POD)
|
||||
_isPod = BaseType == null || (BaseType?.IsPod ?? false);
|
||||
for (int i = 0; _isPod && i < Fields.Count; i++)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user