From 69a0acf63e4eb49884a67afd131dc32d5dc73877 Mon Sep 17 00:00:00 2001 From: walon Date: Wed, 10 Aug 2022 20:22:04 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8D=E4=B8=BAcs=5Funity?= =?UTF-8?q?=5Fjson=E7=94=9F=E6=88=90=20=E5=8F=8D=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E5=8C=96external=20bean=E7=B1=BB=E5=9E=8B=E7=9A=84=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E9=94=99=E8=AF=AFbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Luban.Job.Cfg/Source/TypeVisitors/CsJsonDeserialize.cs | 4 +++- .../Source/TypeVisitors/CsUnityJsonDeserialize.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Luban.Job.Cfg/Source/TypeVisitors/CsJsonDeserialize.cs b/src/Luban.Job.Cfg/Source/TypeVisitors/CsJsonDeserialize.cs index ed0243e..3b8cc23 100644 --- a/src/Luban.Job.Cfg/Source/TypeVisitors/CsJsonDeserialize.cs +++ b/src/Luban.Job.Cfg/Source/TypeVisitors/CsJsonDeserialize.cs @@ -1,6 +1,7 @@ using Luban.Job.Cfg.Datas; using Luban.Job.Common.Types; using Luban.Job.Common.TypeVisitors; +using Luban.Job.Common.Utils; using System; namespace Luban.Job.Cfg.TypeVisitors @@ -80,7 +81,8 @@ namespace Luban.Job.Cfg.TypeVisitors public string Accept(TBean type, string json, string x, int depth) { - return $"{x} = {type.CsUnderingDefineType()}.Deserialize{type.Bean.Name}({json});"; + string src = $"{type.Bean.FullName}.Deserialize{type.Bean.Name}({json});"; + return $"{x} = {ExternalTypeUtil.CsCloneToExternal(type.Bean.FullName, src)};"; } public string Accept(TArray type, string json, string x, int depth) diff --git a/src/Luban.Job.Cfg/Source/TypeVisitors/CsUnityJsonDeserialize.cs b/src/Luban.Job.Cfg/Source/TypeVisitors/CsUnityJsonDeserialize.cs index d85b7f7..16f6b3e 100644 --- a/src/Luban.Job.Cfg/Source/TypeVisitors/CsUnityJsonDeserialize.cs +++ b/src/Luban.Job.Cfg/Source/TypeVisitors/CsUnityJsonDeserialize.cs @@ -1,6 +1,7 @@ using Luban.Job.Cfg.Datas; using Luban.Job.Common.Types; using Luban.Job.Common.TypeVisitors; +using Luban.Job.Common.Utils; using System; namespace Luban.Job.Cfg.TypeVisitors @@ -81,7 +82,8 @@ namespace Luban.Job.Cfg.TypeVisitors public string Accept(TBean type, string json, string x, int depth) { - return $"{{ if(!{json}.IsObject) {{ throw new SerializationException(); }} {x} = {type.CsUnderingDefineType()}.Deserialize{type.Bean.Name}({json}); }}"; + string src = $"{type.Bean.FullName}.Deserialize{type.Bean.Name}({json})"; + return $"{{ if(!{json}.IsObject) {{ throw new SerializationException(); }} {x} = {ExternalTypeUtil.CsCloneToExternal(type.Bean.FullName, src)}; }}"; } public string Accept(TArray type, string json, string x, int depth)