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());
|
||||
|
||||
if (@object is not IEntity entity)
|
||||
{
|
||||
if (@object is IEnumerable enumerable && @object.GetType() != typeof(string))
|
||||
foreach (object? listObject in enumerable)
|
||||
FindEntitiesUnder(listObject);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_entities.Add(entity))
|
||||
return;
|
||||
|
||||
FindEntitiesUnder(entity);
|
||||
|
||||
foreach (PropertyInfo propertyInfo in typeData.Properties)
|
||||
{
|
||||
if (propertyInfo.PropertyType?.IsPrimitive ?? true || propertyInfo.PropertyType == typeof(string))
|
||||
@ -31,12 +34,8 @@ public class EntityFinder
|
||||
if (propertyInfo.HasAttribute<IgnoreSerializationAttribute>())
|
||||
continue;
|
||||
|
||||
object? value = propertyInfo.GetValue(@object);
|
||||
|
||||
if (value is IEnumerable enumerable && value.GetType() != typeof(string))
|
||||
foreach (object? listObject in enumerable)
|
||||
FindEntitiesUnder(listObject);
|
||||
|
||||
if (propertyInfo.GetValue(@object) is object propertyObject)
|
||||
FindEntitiesUnder(propertyObject);
|
||||
}
|
||||
|
||||
foreach (FieldInfo fieldInfo in typeData.Fields)
|
||||
@ -47,14 +46,13 @@ public class EntityFinder
|
||||
if (fieldInfo.HasAttribute<System.Runtime.CompilerServices.CompilerGeneratedAttribute>())
|
||||
continue;
|
||||
|
||||
if (!fieldInfo.HasAttribute<SerializeAttribute>())
|
||||
continue;
|
||||
// if (!fieldInfo.HasAttribute<SerializeAttribute>())
|
||||
// continue;
|
||||
|
||||
object? value = fieldInfo.GetValue(@object);
|
||||
|
||||
if (value is IEnumerable enumerable && value.GetType() != typeof(string))
|
||||
foreach (object? listObject in enumerable)
|
||||
FindEntitiesUnder(listObject);
|
||||
if (fieldInfo.GetValue(@object) is object fieldObject)
|
||||
FindEntitiesUnder(fieldObject);
|
||||
}
|
||||
|
||||
FindEntitiesUnder(entity);
|
||||
}
|
||||
}
|
||||
|
@ -15,11 +15,6 @@ internal static class Utils
|
||||
.Where(pi => pi.SetMethod is not null)
|
||||
.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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user