[fix] 修复 Proto及DB生成时,对于多级继承在某些遍历顺序下 CollectHierarchyFields 的bug
parent
c14437aa59
commit
bcf81ffe26
|
|
@ -166,12 +166,12 @@ namespace Luban.Job.Cfg.Defs
|
|||
|
||||
public List<DefTable> GetAllTables()
|
||||
{
|
||||
return Types.Values.Where(t => t is DefTable).Cast<DefTable>().ToList();
|
||||
return TypeList.Where(t => t is DefTable).Cast<DefTable>().ToList();
|
||||
}
|
||||
|
||||
public List<DefTable> GetExportTables()
|
||||
{
|
||||
return Types.Values.Where(t => t is DefTable ct
|
||||
return TypeList.Where(t => t is DefTable ct
|
||||
&& !_outputExcludeTables.Contains(t.FullName)
|
||||
&& (_outputIncludeTables.Contains(t.FullName) || (_overrideOutputTables == null ? ct.NeedExport : _overrideOutputTables.Contains(ct.FullName)))
|
||||
).Select(t => (DefTable)t).ToList();
|
||||
|
|
@ -313,12 +313,12 @@ namespace Luban.Job.Cfg.Defs
|
|||
|
||||
_cfgServices.AddRange(defines.Services);
|
||||
|
||||
foreach (var type in Types.Values)
|
||||
foreach (var type in TypeList)
|
||||
{
|
||||
type.AssemblyBase = this;
|
||||
}
|
||||
|
||||
foreach (var type in Types.Values)
|
||||
foreach (var type in TypeList)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -332,7 +332,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
throw;
|
||||
}
|
||||
}
|
||||
foreach (var type in Types.Values)
|
||||
foreach (var type in TypeList)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -348,7 +348,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
}
|
||||
}
|
||||
|
||||
foreach (var type in Types.Values)
|
||||
foreach (var type in TypeList)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -158,29 +158,9 @@ namespace Luban.Job.Cfg.Defs
|
|||
return null;
|
||||
}
|
||||
|
||||
private void SetUpParent()
|
||||
{
|
||||
if (ParentDefType == null && !string.IsNullOrEmpty(Parent))
|
||||
{
|
||||
if ((ParentDefType = (DefBean)AssemblyBase.GetDefType(Namespace, Parent)) == null)
|
||||
{
|
||||
throw new Exception($"bean:'{FullName}' parent:'{Parent}' not exist");
|
||||
}
|
||||
if (ParentDefType.Children == null)
|
||||
{
|
||||
ParentDefType.Children = new List<DefBeanBase>();
|
||||
}
|
||||
ParentDefType.Children.Add(this);
|
||||
((DefBean)ParentDefType).SetUpParent();
|
||||
}
|
||||
}
|
||||
|
||||
public override void PreCompile()
|
||||
{
|
||||
SetUpParent();
|
||||
|
||||
CollectHierarchyFields(HierarchyFields);
|
||||
|
||||
base.PreCompile();
|
||||
this.ExportFields = this.Fields.Select(f => (DefField)f).Where(f => f.NeedExport).ToList();
|
||||
this.HierarchyExportFields = this.HierarchyFields.Select(f => (DefField)f).Where(f => f.NeedExport).ToList();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ namespace Luban.Job.Common.Defs
|
|||
|
||||
public Dictionary<string, DefTypeBase> Types { get; } = new Dictionary<string, DefTypeBase>();
|
||||
|
||||
public List<DefTypeBase> TypeList { get; } = new List<DefTypeBase>();
|
||||
|
||||
private readonly Dictionary<string, DefTypeBase> _notCaseSenseTypes = new();
|
||||
|
||||
private readonly HashSet<string> _namespaces = new();
|
||||
|
|
@ -194,6 +196,7 @@ namespace Luban.Job.Common.Defs
|
|||
}
|
||||
|
||||
Types.Add(fullName, type);
|
||||
TypeList.Add(type);
|
||||
}
|
||||
|
||||
public DefTypeBase GetDefType(string fullName)
|
||||
|
|
|
|||
|
|
@ -154,9 +154,9 @@ namespace Luban.Job.Common.Defs
|
|||
fields.AddRange(Fields);
|
||||
}
|
||||
|
||||
public override void PreCompile()
|
||||
private void SetUpParentRecursively()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Parent))
|
||||
if (ParentDefType == null && !string.IsNullOrEmpty(Parent))
|
||||
{
|
||||
if ((ParentDefType = (DefBeanBase)AssemblyBase.GetDefType(Namespace, Parent)) == null)
|
||||
{
|
||||
|
|
@ -167,8 +167,13 @@ namespace Luban.Job.Common.Defs
|
|||
ParentDefType.Children = new List<DefBeanBase>();
|
||||
}
|
||||
ParentDefType.Children.Add(this);
|
||||
ParentDefType.SetUpParentRecursively();
|
||||
}
|
||||
}
|
||||
|
||||
public override void PreCompile()
|
||||
{
|
||||
SetUpParentRecursively();
|
||||
CollectHierarchyFields(HierarchyFields);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,12 +48,12 @@ namespace Luban.Job.Db.Defs
|
|||
AddType(new DefTable(p));
|
||||
}
|
||||
|
||||
foreach (var type in Types.Values)
|
||||
foreach (var type in TypeList)
|
||||
{
|
||||
type.AssemblyBase = this;
|
||||
}
|
||||
|
||||
foreach (var type in Types.Values)
|
||||
foreach (var type in TypeList)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -67,7 +67,7 @@ namespace Luban.Job.Db.Defs
|
|||
throw;
|
||||
}
|
||||
}
|
||||
foreach (var type in Types.Values)
|
||||
foreach (var type in TypeList)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -82,7 +82,7 @@ namespace Luban.Job.Db.Defs
|
|||
throw;
|
||||
}
|
||||
}
|
||||
foreach (var type in Types.Values)
|
||||
foreach (var type in TypeList)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -101,7 +101,7 @@ namespace Luban.Job.Db.Defs
|
|||
|
||||
public List<DefTypeBase> GetExportTypes()
|
||||
{
|
||||
return Types.Values.ToList();
|
||||
return TypeList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,12 +50,12 @@ namespace Luban.Job.Proto.Defs
|
|||
AddType(new DefRpc(r));
|
||||
}
|
||||
|
||||
foreach (var type in Types.Values)
|
||||
foreach (var type in TypeList)
|
||||
{
|
||||
type.AssemblyBase = this;
|
||||
}
|
||||
|
||||
foreach (var type in Types.Values)
|
||||
foreach (var type in TypeList)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -69,7 +69,7 @@ namespace Luban.Job.Proto.Defs
|
|||
throw;
|
||||
}
|
||||
}
|
||||
foreach (var type in Types.Values)
|
||||
foreach (var type in TypeList)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -84,7 +84,7 @@ namespace Luban.Job.Proto.Defs
|
|||
throw;
|
||||
}
|
||||
}
|
||||
foreach (var type in Types.Values)
|
||||
foreach (var type in TypeList)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -104,7 +104,7 @@ namespace Luban.Job.Proto.Defs
|
|||
|
||||
public List<DefTypeBase> GetExportTypes()
|
||||
{
|
||||
return Types.Values.ToList();
|
||||
return TypeList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue