diff --git a/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs index 8b08a4a..3f5189a 100644 --- a/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs @@ -214,6 +214,10 @@ namespace Luban.Job.Cfg.DataCreators { return null; } + if (d == null) + { + throw new InvalidExcelDataException($"枚举值不能为空"); + } return new DEnum(type, d.ToString().Trim()); } diff --git a/src/Luban.Job.Cfg/Source/DataCreators/MultiRowExcelDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/MultiRowExcelDataCreator.cs deleted file mode 100644 index 68d392b..0000000 --- a/src/Luban.Job.Cfg/Source/DataCreators/MultiRowExcelDataCreator.cs +++ /dev/null @@ -1,163 +0,0 @@ -//using Luban.Job.Cfg.Datas; -//using Luban.Job.Cfg.DataSources.Excel; -//using Luban.Job.Cfg.Defs; -//using Luban.Job.Common.Types; -//using Luban.Job.Common.TypeVisitors; -//using System; -//using System.Collections.Generic; - -//namespace Luban.Job.Cfg.DataCreators -//{ -// class MultiRowExcelDataCreator : ITypeFuncVisitor, bool, DefAssembly, DType> -// { -// public static MultiRowExcelDataCreator Ins { get; } = new MultiRowExcelDataCreator(); - -// public DType Accept(TBool type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TByte type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TShort type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TFshort type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TInt type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TFint type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TLong type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TFlong type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TFloat type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TDouble type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TEnum type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TString type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TBytes type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TText type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TBean type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// private List ReadMultiRow(TType type, IEnumerable rows, DefAssembly ass) -// { -// var list = new List(); -// foreach (var stream in rows) -// { -// try -// { -// list.Add(type.Apply(ExcelStreamDataCreator.Ins, null, stream, ass)); -// } -// catch (Exception e) -// { -// var dce = new DataCreateException(e, stream.LastReadDataInfo); -// throw dce; -// } -// } -// return list; -// } - -// public DType Accept(TArray type, IEnumerable x, bool y, DefAssembly ass) -// { -// return new DArray(type, ReadMultiRow(type.ElementType, x, ass)); -// } - -// public DType Accept(TList type, IEnumerable x, bool y, DefAssembly ass) -// { -// return new DList(type, ReadMultiRow(type.ElementType, x, ass)); -// } - -// public DType Accept(TSet type, IEnumerable x, bool y, DefAssembly ass) -// { -// return new DSet(type, ReadMultiRow(type.ElementType, x, ass)); -// } - -// public DType Accept(TMap type, IEnumerable rows, bool y, DefAssembly ass) -// { -// var map = new Dictionary(); -// foreach (var stream in rows) -// { -// try -// { -// DType key = type.KeyType.Apply(ExcelStreamDataCreator.Ins, null, stream, ass); -// DType value = type.ValueType.Apply(ExcelStreamDataCreator.Ins, null, stream, ass); -// map.Add(key, value); -// } -// catch (Exception e) -// { -// var dce = new DataCreateException(e, stream.LastReadDataInfo); -// throw dce; -// } -// } -// return new DMap(type, map); -// } - -// public DType Accept(TVector2 type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TVector3 type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TVector4 type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } - -// public DType Accept(TDateTime type, IEnumerable x, bool y, DefAssembly ass) -// { -// throw new NotImplementedException(); -// } -// } -//} diff --git a/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs index 2759956..802543f 100644 --- a/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs @@ -196,6 +196,10 @@ namespace Luban.Job.Cfg.DataCreators { return null; } + if (x == null) + { + throw new InvalidExcelDataException($"枚举值不能为空"); + } return new DEnum(type, x.ToString()); } @@ -291,7 +295,7 @@ namespace Luban.Job.Cfg.DataCreators } catch (Exception e) { - var dce = new DataCreateException(e, $"字段:{fname}"); + var dce = new DataCreateException(e, $"字段:{fname} 位置:{field.Location}"); dce.Push(bean, f); throw dce; } diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/TitleRow.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/TitleRow.cs index 1e3aae9..4636497 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/Excel/TitleRow.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/TitleRow.cs @@ -38,6 +38,30 @@ namespace Luban.Job.Cfg.DataSources.Excel public List Elements { get; } + public string Location + { + get + { + if (Row != null) + { + return Row[SelfTitle.FromIndex].ToString(); + } + if (Rows != null) + { + return Rows[0][SelfTitle.FromIndex].ToString(); + } + if (Fields != null) + { + return Fields[SelfTitle.SubTitleList[0].Name].Location; + } + if (Elements != null) + { + return Elements.Count > 0 ? Elements[0].Location : "无法定位"; + } + return "无法定位"; + } + } + public ExcelStream AsStream(string sep) { if (string.IsNullOrEmpty(SelfTitle.Sep)) diff --git a/src/Luban.Job.Common/Source/Defs/DefFieldBase.cs b/src/Luban.Job.Common/Source/Defs/DefFieldBase.cs index b69007b..7dfe715 100644 --- a/src/Luban.Job.Common/Source/Defs/DefFieldBase.cs +++ b/src/Luban.Job.Common/Source/Defs/DefFieldBase.cs @@ -25,7 +25,7 @@ namespace Luban.Job.Common.Defs ELanguage curLan = AssemblyBase.CurrentLanguage; switch (AssemblyBase.NamingConventionBeanMember) { - case NamingConvention.Origin: cn = Name; break; + case NamingConvention.None: cn = Name; break; case NamingConvention.CameraCase: cn = TypeUtil.ToCamelCase(Name); break; case NamingConvention.PascalCase: cn = TypeUtil.ToPascalCase(Name); break; case NamingConvention.UnderScores: cn = TypeUtil.ToUnderScores(Name); break; diff --git a/src/Luban.Job.Common/Source/GenArgsBase.cs b/src/Luban.Job.Common/Source/GenArgsBase.cs index b086350..fb9121f 100644 --- a/src/Luban.Job.Common/Source/GenArgsBase.cs +++ b/src/Luban.Job.Common/Source/GenArgsBase.cs @@ -28,22 +28,22 @@ namespace Luban.Job.Common [Option("use_unity_vector", Required = false, HelpText = "use UnityEngine.Vector{2,3,4}")] public bool UseUnityVectors { get; set; } - [Option("naming_convention_module", Required = false, HelpText = "naming convention of module. can be language_recommend,origin,camelCase,PascalCase,under_scores")] + [Option("naming_convention_module", Required = false, HelpText = "naming convention of module. can be language_recommend,none,camelCase,PascalCase,under_scores")] public string NamingConventionModuleStr { get; set; } public NamingConvention NamingConventionModule { get; set; } - [Option("naming_convention_type", Required = false, HelpText = "naming convention of enum and bean. can be language_recommend,origin,camelCase,PascalCase,under_scores")] + [Option("naming_convention_type", Required = false, HelpText = "naming convention of enum and bean. can be language_recommend,none,camelCase,PascalCase,under_scores")] public string NamingConventionTypeStr { get; set; } public NamingConvention NamingConventionType { get; set; } - [Option("naming_convention_bean_member", Required = false, HelpText = "naming convention of bean member. can be language_recommend,origin,camelCase,PascalCase,under_scores")] + [Option("naming_convention_bean_member", Required = false, HelpText = "naming convention of bean member. can be language_recommend,none,camelCase,PascalCase,under_scores")] public string NamingConventionBeanMemberStr { get; set; } public NamingConvention NamingConventionBeanMember { get; set; } - [Option("naming_convention_enum_member", Required = false, HelpText = "naming convention of enum member. can be language_recommend,origin,camelCase,PascalCase,under_scores")] + [Option("naming_convention_enum_member", Required = false, HelpText = "naming convention of enum member. can be language_recommend,none,camelCase,PascalCase,under_scores")] public string NamingConventionEnumMemberStr { get; set; } public NamingConvention NamingConventionEnumMember { get; set; } @@ -70,7 +70,7 @@ namespace Luban.Job.Common case null: case "": case "language_recommend": result = NamingConvention.LanguangeRecommend; return true; - case "origin": result = NamingConvention.Origin; return true; + case "none": result = NamingConvention.None; return true; case "camelCase": result = NamingConvention.CameraCase; return true; case "PascalCase": result = NamingConvention.PascalCase; return true; case "under_scores": result = NamingConvention.UnderScores; return true; @@ -118,25 +118,25 @@ namespace Luban.Job.Common { if (!TryParseNamingConvention(NamingConventionModuleStr, out var m)) { - errMsg = "--naming_convention_module invalid! valid values: language_recommend,origin,camelCase,PascalCase,under_scores"; + errMsg = "--naming_convention_module invalid! valid values: language_recommend,none,camelCase,PascalCase,under_scores"; return false; } NamingConventionModule = m; if (!TryParseNamingConvention(NamingConventionTypeStr, out var t)) { - errMsg = "--naming_convention_type invalid! valid values: language_recommend,origin,camelCase,PascalCase,under_scores"; + errMsg = "--naming_convention_type invalid! valid values: language_recommend,none,camelCase,PascalCase,under_scores"; return false; } NamingConventionType = t; if (!TryParseNamingConvention(NamingConventionBeanMemberStr, out var bm)) { - errMsg = "--naming_convention_bean_member invalid! valid values: language_recommend,origin,camelCase,PascalCase,under_scores"; + errMsg = "--naming_convention_bean_member invalid! valid values: language_recommend,none,camelCase,PascalCase,under_scores"; return false; } NamingConventionBeanMember = bm; if (!TryParseNamingConvention(NamingConventionEnumMemberStr, out var em)) { - errMsg = "--naming_convention_enum_member invalid! valid values: language_recommend,origin,camelCase,PascalCase,under_scores"; + errMsg = "--naming_convention_enum_member invalid! valid values: language_recommend,none,camelCase,PascalCase,under_scores"; return false; } NamingConventionEnumMember = em; diff --git a/src/Luban.Job.Common/Source/NamingConvention.cs b/src/Luban.Job.Common/Source/NamingConvention.cs index 196e314..122127f 100644 --- a/src/Luban.Job.Common/Source/NamingConvention.cs +++ b/src/Luban.Job.Common/Source/NamingConvention.cs @@ -10,7 +10,7 @@ namespace Luban.Job.Common { Invalid, LanguangeRecommend, - Origin, + None, CameraCase, PascalCase, UnderScores,