Skip to content

Commit

Permalink
If it is a List type and contains an Enum, delete the condition that …
Browse files Browse the repository at this point in the history
…must not be Nullable.
  • Loading branch information
elky84 committed Dec 28, 2023
1 parent d22bb54 commit 4b991ff
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ExcelCli/ExcelCli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackAsTool>true</PackAsTool>
<ToolCommandName>excel2dotnet</ToolCommandName>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>1.0.35</Version>
<Version>1.0.36</Version>

<PackageDescription>Excel To Dotnet</PackageDescription>
<RepositoryUrl>https://github.com/elky84/ExcelToDotnet</RepositoryUrl>
Expand All @@ -23,7 +23,7 @@
</ItemGroup>

<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ExcelToDotnet/ExcelToDotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>

<PackageId>ExcelToDotnet</PackageId>
<Version>1.0.35</Version>
<Version>1.0.36</Version>
<Authors>elky</Authors>
<Company>elky</Company>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
2 changes: 1 addition & 1 deletion ExcelToDotnet/Extend/CodeGenerateExtend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void GenerateCode(this List<string> strings, StreamWriter outputFi
{
strings.Insert(insertIndex, string.Format($" [JsonConverter(typeof(JsonEnumConverter<{dataType.RemoveSpecialCharacters()}>))]"));
}
else if (dataType.StartsWith("List") && (dataType.EndsWith("Type>?") || dataType.EndsWith("Type>")))
else if (dataType.StartsWith("List") && (dataType.EndsWith("Type>?") || dataType.EndsWith("Type>") || dataType.EndsWith("Type?>")))
{
strings.Insert(insertIndex, string.Format($" [JsonConverter(typeof(JsonEnumsConverter<{dataType.ExtractDataTypeInList().RemoveSpecialCharacters()}>))]"));
}
Expand Down
11 changes: 1 addition & 10 deletions ExcelToDotnet/Validation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -570,21 +570,12 @@ public static void ValidateDataType(this DataTable dt, string keyword, List<stri
continue;
}

if (IsListType(dataType))
{
if (dataType.Contains("Type") && dataType.Contains("?>"))
{
Failed($"[{keyword}] List타입이고, Enum을 담고 있다면 Nullable이 아니어야만 합니다 <Table:{dt.TableName}, Column:{dt.Columns[index].ColumnName}, dataType:{dataType}>");
}
continue;
}

if (File.Exists($"output/{keyword}/{dataType}.Json"))
{
continue;
}

if (!dataType.EndsWith("Type") && !dataType.EndsWith("Type?"))
if (!IsListType(dataType) && !dataType.EndsWith("Type") && !dataType.EndsWith("Type?"))
{
Failed($"[{keyword}] 참조 컬럼이 아니고, 기본형 타입, List 타입이 아니라면, Type 또는 Type? 으로 끝나야 합니다. <Table:{dt.TableName}, Column:{dt.Columns[index].ColumnName}, dataType:{dataType}>");
}
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ execute file name `excel2dotnet` instead of `ExcelCli`

## Version History

### v1.0.36
* If it is a List type and contains an Enum, delete the condition that must not be Nullable.

### v1.0.35
* Fix Probability validation error.

Expand Down

0 comments on commit 4b991ff

Please sign in to comment.