fix: fixed fields/properties like behaviour controllers not being explored by entity finder
This commit is contained in:
parent
9581f5aa54
commit
2637f99456
@ -16,13 +16,16 @@ public class EntityFinder
|
|||||||
TypeData typeData = Utils.GetTypeData(@object.GetType());
|
TypeData typeData = Utils.GetTypeData(@object.GetType());
|
||||||
|
|
||||||
if (@object is not IEntity entity)
|
if (@object is not IEntity entity)
|
||||||
|
{
|
||||||
|
if (@object is IEnumerable enumerable && @object.GetType() != typeof(string))
|
||||||
|
foreach (object? listObject in enumerable)
|
||||||
|
FindEntitiesUnder(listObject);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!_entities.Add(entity))
|
if (!_entities.Add(entity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FindEntitiesUnder(entity);
|
|
||||||
|
|
||||||
foreach (PropertyInfo propertyInfo in typeData.Properties)
|
foreach (PropertyInfo propertyInfo in typeData.Properties)
|
||||||
{
|
{
|
||||||
if (propertyInfo.PropertyType?.IsPrimitive ?? true || propertyInfo.PropertyType == typeof(string))
|
if (propertyInfo.PropertyType?.IsPrimitive ?? true || propertyInfo.PropertyType == typeof(string))
|
||||||
@ -31,12 +34,8 @@ public class EntityFinder
|
|||||||
if (propertyInfo.HasAttribute<IgnoreSerializationAttribute>())
|
if (propertyInfo.HasAttribute<IgnoreSerializationAttribute>())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
object? value = propertyInfo.GetValue(@object);
|
if (propertyInfo.GetValue(@object) is object propertyObject)
|
||||||
|
FindEntitiesUnder(propertyObject);
|
||||||
if (value is IEnumerable enumerable && value.GetType() != typeof(string))
|
|
||||||
foreach (object? listObject in enumerable)
|
|
||||||
FindEntitiesUnder(listObject);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (FieldInfo fieldInfo in typeData.Fields)
|
foreach (FieldInfo fieldInfo in typeData.Fields)
|
||||||
@ -47,14 +46,13 @@ public class EntityFinder
|
|||||||
if (fieldInfo.HasAttribute<System.Runtime.CompilerServices.CompilerGeneratedAttribute>())
|
if (fieldInfo.HasAttribute<System.Runtime.CompilerServices.CompilerGeneratedAttribute>())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!fieldInfo.HasAttribute<SerializeAttribute>())
|
// if (!fieldInfo.HasAttribute<SerializeAttribute>())
|
||||||
continue;
|
// continue;
|
||||||
|
|
||||||
object? value = fieldInfo.GetValue(@object);
|
if (fieldInfo.GetValue(@object) is object fieldObject)
|
||||||
|
FindEntitiesUnder(fieldObject);
|
||||||
if (value is IEnumerable enumerable && value.GetType() != typeof(string))
|
|
||||||
foreach (object? listObject in enumerable)
|
|
||||||
FindEntitiesUnder(listObject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FindEntitiesUnder(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,6 @@ internal static class Utils
|
|||||||
.Where(pi => pi.SetMethod is not null)
|
.Where(pi => pi.SetMethod is not null)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
propertyInfos.AddRange(
|
|
||||||
GetPropertyInfosIncludingBaseClasses(objectType, BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.NonPublic)
|
|
||||||
.Where(pi => pi.SetMethod is not null && pi.GetCustomAttribute<SerializeAttribute>() is not null)
|
|
||||||
);
|
|
||||||
|
|
||||||
return new TypeData(fieldInfos, propertyInfos);
|
return new TypeData(fieldInfos, propertyInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user