parent
b123a61081
commit
a36b118a98
|
|
@ -69,7 +69,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
|
||||
public Dictionary<DType, DBean> GetTableDataMap(DefTable table)
|
||||
{
|
||||
return _recordsMapByTables.GetValueOrDefault(table.FullName);
|
||||
return _recordsMapByTables[table.FullName];
|
||||
}
|
||||
|
||||
public List<DefTable> GetExportTables()
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
public RefValidator Ref { get; private set; }
|
||||
|
||||
// 对于 two key map, 需要检查 ref,但不为它生成 ref 代码.故只有map类型表才要生成代码
|
||||
public bool GenRef => Ref != null && Assembly.GetCfgTable(Ref.FirstTable).IsMapTable;
|
||||
public bool GenRef => Ref != null && Ref.Tables.Count == 1 && Assembly.GetCfgTable(Ref.FirstTable).IsMapTable;
|
||||
|
||||
public bool HasRecursiveRef => (CType is TBean)
|
||||
|| (CType is TArray ta && ta.ElementType is TBean)
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ namespace Luban.Job.Cfg
|
|||
}
|
||||
|
||||
public async Task ValidateTables(IEnumerable<DefTable> tables)
|
||||
{
|
||||
{
|
||||
var tasks = new List<Task>();
|
||||
foreach (var t in tables)
|
||||
|
|
@ -68,7 +69,18 @@ namespace Luban.Job.Cfg
|
|||
{
|
||||
var records = t.Assembly.GetTableDataList(t);
|
||||
ValidateTableModeIndex(t, records);
|
||||
}));
|
||||
}
|
||||
await Task.WhenAll(tasks);
|
||||
}
|
||||
|
||||
{
|
||||
var tasks = new List<Task>();
|
||||
foreach (var t in tables)
|
||||
{
|
||||
tasks.Add(Task.Run(() =>
|
||||
{
|
||||
var records = t.Assembly.GetTableDataList(t);
|
||||
var visitor = new ValidatorVisitor(this);
|
||||
try
|
||||
{
|
||||
|
|
@ -82,6 +94,8 @@ namespace Luban.Job.Cfg
|
|||
}));
|
||||
}
|
||||
await Task.WhenAll(tasks);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(RootDir))
|
||||
{
|
||||
await ValidatePaths();
|
||||
|
|
|
|||
|
|
@ -54,13 +54,27 @@ namespace Luban.Job.Cfg.Validators
|
|||
}
|
||||
DefTable ct = assembly.GetCfgTable(actualTable);
|
||||
var recordMap = assembly.GetTableDataMap(ct);
|
||||
if (recordMap != null && !recordMap.ContainsKey(key))
|
||||
if (/*recordMap != null &&*/ recordMap.ContainsKey(key))
|
||||
{
|
||||
string source = DataUtil.GetSourceFile(ValidatorContext.CurrentVisitor.CurrentValidateRecord);
|
||||
assembly.Agent.Error("记录 {0} = {1} (来自文件:{2}) 在引用表:{3} 中不存在", ValidatorContext.CurrentRecordPath, key, source, table);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var table in Tables)
|
||||
{
|
||||
string actualTable;
|
||||
if (table.EndsWith("?"))
|
||||
{
|
||||
actualTable = table[0..^1];
|
||||
}
|
||||
else
|
||||
{
|
||||
actualTable = table;
|
||||
}
|
||||
DefTable ct = assembly.GetCfgTable(actualTable);
|
||||
string source = DataUtil.GetSourceFile(ValidatorContext.CurrentVisitor.CurrentValidateRecord);
|
||||
assembly.Agent.Error("记录 {0} = {1} (来自文件:{2}) 在引用表:{3} 中不存在", ValidatorContext.CurrentRecordPath, key, source, table);
|
||||
}
|
||||
}
|
||||
|
||||
public void Compile(DefField def)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using Luban.Config.Common.RawDefs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Luban.Job.Cfg.Validators
|
||||
{
|
||||
|
|
@ -14,7 +15,7 @@ namespace Luban.Job.Cfg.Validators
|
|||
{
|
||||
case RefValidator.NAME:
|
||||
{
|
||||
return new RefValidator(new List<string> { validator.Rule });
|
||||
return new RefValidator(validator.Rule.Split(',').ToList());
|
||||
}
|
||||
case PathValidator.NAME:
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue