[fix] 修复Cfg DefBean.PreCompile中CollectHierarchyFields时由于顺序原因有可能发生祖父及更高层级的类的ParentDefType字段未设置导致的未能收集到所有字段的恶劣bug

main
walon 2023-02-28 20:36:43 +08:00
parent 16e4fe2452
commit c14437aa59
1 changed files with 8 additions and 2 deletions

View File

@ -158,9 +158,9 @@ namespace Luban.Job.Cfg.Defs
return null; return null;
} }
public override void PreCompile() private void SetUpParent()
{ {
if (!string.IsNullOrEmpty(Parent)) if (ParentDefType == null && !string.IsNullOrEmpty(Parent))
{ {
if ((ParentDefType = (DefBean)AssemblyBase.GetDefType(Namespace, Parent)) == null) if ((ParentDefType = (DefBean)AssemblyBase.GetDefType(Namespace, Parent)) == null)
{ {
@ -171,7 +171,13 @@ namespace Luban.Job.Cfg.Defs
ParentDefType.Children = new List<DefBeanBase>(); ParentDefType.Children = new List<DefBeanBase>();
} }
ParentDefType.Children.Add(this); ParentDefType.Children.Add(this);
((DefBean)ParentDefType).SetUpParent();
} }
}
public override void PreCompile()
{
SetUpParent();
CollectHierarchyFields(HierarchyFields); CollectHierarchyFields(HierarchyFields);