From 412a400471d796fccb423eaa68609d6bc02f022f Mon Sep 17 00:00:00 2001 From: walon Date: Thu, 28 Jul 2022 17:02:31 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8Dref=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E4=BA=86=E8=A2=AB=E8=BF=87=E6=BB=A4=E7=9A=84=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=8D=B4=E6=9C=AA=E6=8A=A5=E5=91=8A=E5=BC=95=E7=94=A8=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs | 3 +++ .../Source/Validators/RefValidator.cs | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs b/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs index da64749..2b0fbbb 100644 --- a/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs +++ b/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs @@ -24,6 +24,7 @@ namespace Luban.Job.Cfg.Defs public Service CfgTargetService { get; private set; } private readonly string _patchName; + private readonly List _excludeTags; public Patch TargetPatch { get; private set; } @@ -34,6 +35,8 @@ namespace Luban.Job.Cfg.Defs public string TableManagerName => CfgTargetService.Manager; + public List ExcludeTags => _excludeTags; + public DefAssembly(string patchName, TimeZoneInfo timezone, List excludeTags, IAgent agent) { this._patchName = patchName; diff --git a/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs b/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs index c5ade92..4a0b33b 100644 --- a/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs +++ b/src/Luban.Job.Cfg/Source/Validators/RefValidator.cs @@ -1,4 +1,5 @@ using Luban.Job.Cfg.Datas; +using Luban.Job.Cfg.DataSources; using Luban.Job.Cfg.DataVisitors; using Luban.Job.Cfg.Defs; using Luban.Job.Cfg.RawDefs; @@ -58,8 +59,14 @@ namespace Luban.Job.Cfg.Validators case ETableMode.MAP: { var recordMap = assembly.GetTableDataInfo(defTable).FinalRecordMap; - if (recordMap.ContainsKey(key)) + if (recordMap.TryGetValue(key, out Record rec)) { + if (!rec.IsNotFiltered(assembly.ExcludeTags)) + { + string locationFile = ValidatorContext.CurrentVisitor.CurrentValidateRecord.Source; + assembly.Agent.Error("记录 {0} = {1} (来自文件:{2}) 在引用表:{3} 中存在,但导出时被过滤了", + ValidatorContext.CurrentRecordPath, key, locationFile, defTable.FullName); + } return; } break; @@ -67,8 +74,14 @@ namespace Luban.Job.Cfg.Validators case ETableMode.LIST: { var recordMap = assembly.GetTableDataInfo(defTable).FinalRecordMapByIndexs[field]; - if (recordMap.ContainsKey(key)) + if (recordMap.TryGetValue(key, out Record rec)) { + if (!rec.IsNotFiltered(assembly.ExcludeTags)) + { + string locationFile = ValidatorContext.CurrentVisitor.CurrentValidateRecord.Source; + assembly.Agent.Error("记录 {0} = {1} (来自文件:{2}) 在引用表:{3} 中存在,但导出时被过滤了", + ValidatorContext.CurrentRecordPath, key, locationFile, defTable.FullName); + } return; } break;