Selaa lähdekoodia

Merge pull request #7 from LithWang/master

# 2.4.0
Lith 4 kuukautta sitten
vanhempi
commit
9d07c62d4e

+ 6 - 1
Publish/DevOps3/README.md

@@ -1,5 +1,5 @@
 
-# DevOps 3.7
+# DevOps 3.8
 
 
 # build-bash
@@ -24,6 +24,11 @@ if this file exists, will not need approval for jenkins build.
 ----------------------------------------------
 # ReleaseLog
 
+-----------------------
+# 3.8
+> 2024-12-19
+- upgrade net to 8.0
+
 -----------------------
 # 3.7
 > 2024-09-21

+ 1 - 1
Publish/DevOps3/build-bash/10.Test.bash

@@ -37,7 +37,7 @@ docker run -i --rm \
 -v $NUGET_PATH:/root/.nuget \
 -v "$basePath":/root/code \
 -v "$basePath":"$basePath" \
-serset/dotnet:sdk-6.0 \
+serset/dotnet:sdk-8.0 \
 bash -c "
 set -e
 

+ 1 - 1
Publish/DevOps3/build-bash/30.nuget-pack.sh

@@ -22,7 +22,7 @@ docker run -i --rm \
 --env LANG=C.UTF-8 \
 -v $NUGET_PATH:/root/.nuget \
 -v $basePath:/root/code \
-serset/dotnet:sdk-6.0 \
+serset/dotnet:sdk-8.0 \
 bash -c "
 
 publishPath=/root/code/Publish/release/release/nuget

+ 1 - 1
Publish/DevOps3/build-bash/40.Station-publish.sh

@@ -23,7 +23,7 @@ docker run -i --rm \
 -v $NUGET_PATH:/root/.nuget \
 -v "$basePath":/root/code \
 -v "$basePath":"$basePath" \
-serset/dotnet:sdk-6.0 \
+serset/dotnet:sdk-8.0 \
 bash -c "
 set -e
 

+ 1 - 1
Publish/DevOps3/release-bash/72.nuget-push.sh

@@ -25,7 +25,7 @@ fi
 docker run -i --rm \
 --env LANG=C.UTF-8 \
 -v $basePath:/root/code \
-serset/dotnet:sdk-6.0 \
+serset/dotnet:sdk-8.0 \
 bash -c "
 for file in /root/code/Publish/release/release/nuget/*.nupkg
 do

+ 5 - 0
doc/ReleaseNotes.md

@@ -1,5 +1,10 @@
 # Vitorm.Excel ReleaseNotes
 
+-----------------------
+# 2.4.0
+- upgrade to net8
+- fix the issue that can not load sheet if column name is empty
+
 -----------------------
 # 2.2.0
 

+ 2 - 2
src/Versions.props

@@ -1,7 +1,7 @@
 <Project>
     <PropertyGroup>
-        <Version>2.2.2</Version>
-        <Vitorm_Version>[2.2.2, 2.3.0)</Vitorm_Version>
+        <Version>2.4.0</Version>
+        <Vitorm_Version>[2.4.0, 2.5.0)</Vitorm_Version>
     </PropertyGroup>
 
     <PropertyGroup>

+ 11 - 9
src/Vitorm.Excel/DbSet.cs

@@ -69,7 +69,9 @@ namespace Vitorm.Excel
             _columnIndexes ??=
                 Enumerable.Range(1, sheet.Dimension?.End.Column ?? 0)
                 .Select(i => (index: i, columnName: sheet.GetValue<string>(1, i)))
-                .GroupBy(m => m.columnName).Select(g => g.First())
+                .GroupBy(m => m.columnName)
+                .Where(g => !string.IsNullOrWhiteSpace(g.Key))
+                .Select(g => g.First())
                 .ToDictionary(item => item.columnName, item => item.index)
             ;
         #endregion
@@ -100,7 +102,7 @@ namespace Vitorm.Excel
 
         public virtual void AddColumnsIfNotExist()
         {
-            var colsToAdd = entityDescriptor.allColumns.Where(col => !columnIndexes.TryGetValue(col.columnName, out var _)).ToList();
+            var colsToAdd = entityDescriptor.properties.Where(col => !columnIndexes.TryGetValue(col.columnName, out var _)).ToList();
 
             if (!colsToAdd.Any()) return;
 
@@ -118,7 +120,7 @@ namespace Vitorm.Excel
 
         public virtual void SetDateTimeFormat(string format = "yyyy-MM-dd HH:mm:ss")
         {
-            foreach (var col in entityDescriptor.allColumns.Where(col => TypeUtil.GetUnderlyingType(col.type) == typeof(DateTime)))
+            foreach (var col in entityDescriptor.properties.Where(col => TypeUtil.GetUnderlyingType(col.type) == typeof(DateTime)))
             {
                 if (!columnIndexes.TryGetValue(col.columnName, out var colIndex)) continue;
 
@@ -132,7 +134,7 @@ namespace Vitorm.Excel
 
         protected virtual void SetRow(Entity entity, int rowIndex)
         {
-            foreach (var col in entityDescriptor.allColumns)
+            foreach (var col in entityDescriptor.properties)
             {
                 if (!columnIndexes.TryGetValue(col.columnName, out var colIndex)) continue;
                 var value = col.GetValue(entity);
@@ -179,7 +181,7 @@ namespace Vitorm.Excel
                 var entity = (Entity)Activator.CreateInstance(entityDescriptor.entityType);
                 try
                 {
-                    foreach (var col in entityDescriptor.allColumns)
+                    foreach (var col in entityDescriptor.properties)
                     {
                         if (!columnIndexes.TryGetValue(col.columnName, out var colIndex)) continue;
 
@@ -237,7 +239,7 @@ namespace Vitorm.Excel
             var sheet = package.Workbook.Worksheets.Add(entityDescriptor.tableName);
 
             int colIndex = 0;
-            foreach (var col in entityDescriptor.allColumns)
+            foreach (var col in entityDescriptor.properties)
             {
                 colIndex++;
 
@@ -258,7 +260,7 @@ namespace Vitorm.Excel
             var sheet = package.Workbook.Worksheets.Add(entityDescriptor.tableName);
 
             int colIndex = 0;
-            foreach (var col in entityDescriptor.allColumns)
+            foreach (var col in entityDescriptor.properties)
             {
                 colIndex++;
 
@@ -334,7 +336,7 @@ namespace Vitorm.Excel
                 entities.ForEach(entity =>
                 {
                     object keyValue = entityDescriptor.key.GetValue(entity);
-                    var keyIsEmpty = keyValue is null || keyValue.Equals(TypeUtil.DefaultValue(entityDescriptor.key.type));
+                    var keyIsEmpty = keyValue is null || keyValue.Equals(TypeUtil.GetDefaultValue(entityDescriptor.key.type));
                     if (keyIsEmpty)
                     {
                         maxId++;
@@ -375,7 +377,7 @@ namespace Vitorm.Excel
                 entities.ForEach(entity =>
                 {
                     object keyValue = entityDescriptor.key.GetValue(entity);
-                    var keyIsEmpty = keyValue is null || keyValue.Equals(TypeUtil.DefaultValue(entityDescriptor.key.type));
+                    var keyIsEmpty = keyValue is null || keyValue.Equals(TypeUtil.GetDefaultValue(entityDescriptor.key.type));
                     if (keyIsEmpty)
                     {
                         maxId++;

+ 1 - 1
src/Vitorm.Excel/Vitorm.Excel.csproj

@@ -32,7 +32,7 @@
     </ItemGroup>
 
     <ItemGroup>
-        <PackageReference Include="EPPlus" Version="7.4.1" />
+        <PackageReference Include="EPPlus" Version="7.5.2" />
         <PackageReference Include="Vitorm" Version="$(Vitorm_Version)" />
     </ItemGroup>
 

+ 4 - 4
test/Vitorm.Excel.Data.MsTest/Vitorm.Excel.Data.MsTest.csproj

@@ -6,7 +6,7 @@
     </PropertyGroup>
 
     <PropertyGroup>
-        <TargetFramework>net6.0</TargetFramework>
+        <TargetFramework>net8.0</TargetFramework>
         <ImplicitUsings>enable</ImplicitUsings>
 
         <IsPackable>false</IsPackable>
@@ -15,9 +15,9 @@
     </PropertyGroup>
 
     <ItemGroup>
-        <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
-        <PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
-        <PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
+        <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
+        <PackageReference Include="MSTest.TestAdapter" Version="3.6.4" />
+        <PackageReference Include="MSTest.TestFramework" Version="3.6.4" />
 
         <PackageReference Include="Vit.Core" Version="2.3.0" />
         <PackageReference Include="Vitorm.Data" Version="$(Vitorm_Version)" />

+ 10 - 5
test/Vitorm.Excel.MsTest/CommonTest/EntityLoader_CustomLoader_Test.cs

@@ -4,6 +4,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
 
 using Vitorm.Entity;
 using Vitorm.Entity.Loader.DataAnnotations;
+using Vitorm.Entity.PropertyType;
 
 namespace Vitorm.MsTest.CommonTest
 {
@@ -120,7 +121,7 @@ namespace Vitorm.MsTest.CommonTest
             {
                 if (!GetTableName(entityType, out var tableName, out var schema)) return default;
 
-                IColumnDescriptor[] allColumns = entityType?.GetProperties(BindingFlags.Public | BindingFlags.Instance)
+                var propertyDescriptors = entityType?.GetProperties(BindingFlags.Public | BindingFlags.Instance)
                     .Select(propertyInfo =>
                     {
                         var labels = propertyInfo?.GetCustomAttributes<LabelAttribute>();
@@ -152,15 +153,19 @@ namespace Vitorm.MsTest.CommonTest
                             }
                         }
 
-                        return new ColumnDescriptor(
-                            propertyInfo, columnName: columnName,
+                        return new PropertyDescriptor(
+                            propertyInfo, propertyType: new PropertyValueType(propertyInfo.PropertyType),
+                            columnName: columnName,
                             isKey: isKey, isIdentity: isIdentity, isNullable: isNullable,
                             columnDbType: columnDbType,
                             columnOrder: columnOrder
                             );
-                    }).Where(column => column != null).ToArray();
+                    }).Where(column => column != null);
 
-                return (true, new EntityDescriptor(entityType, allColumns, tableName, schema));
+                var propertyType = new PropertyObjectType(entityType);
+                propertyType.properties = propertyDescriptors.Select(m => (IPropertyDescriptor)m).ToArray();
+
+                return (true, new EntityDescriptor(propertyType, tableName, schema));
             }
         }
         #endregion

+ 5 - 5
test/Vitorm.Excel.MsTest/Vitorm.Excel.MsTest.csproj

@@ -5,7 +5,7 @@
     </PropertyGroup>
 
     <PropertyGroup>
-        <TargetFramework>net6.0</TargetFramework>
+        <TargetFramework>net8.0</TargetFramework>
         <ImplicitUsings>enable</ImplicitUsings>
 
         <IsPackable>false</IsPackable>
@@ -14,10 +14,10 @@
     </PropertyGroup>
 
     <ItemGroup>
-        <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
-        <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
-        <PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
-        <PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
+        <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.0" />
+        <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
+        <PackageReference Include="MSTest.TestAdapter" Version="3.6.4" />
+        <PackageReference Include="MSTest.TestFramework" Version="3.6.4" />
 
         <PackageReference Include="Vit.Core" Version="2.3.0" />
     </ItemGroup>