Piotr Czajkowski 3 hónapja
szülő
commit
88d36c7967

+ 0 - 1
ExcelORM/ExcelORM/ExcelDynamicReader.cs

@@ -35,7 +35,6 @@ public class ExcelDynamicReader : IDisposable
                     continue;
                 }
 
-                item.Type ??= cell.Value.ValueType();
                 var cellItem = item with
                 {
                     Value = cell.Value.ToObject()

+ 2 - 3
ExcelORM/ExcelORM/ExcelORM.csproj

@@ -4,7 +4,7 @@
         <TargetFramework>net8.0</TargetFramework>
         <ImplicitUsings>enable</ImplicitUsings>
         <Nullable>enable</Nullable>
-        <Version>3.0.0</Version>
+        <Version>3.0.1</Version>
         <PackageProjectUrl>https://git.liox.eu/pczajkowski/ExcelORM</PackageProjectUrl>
         <RepositoryUrl>https://github.com/pczajkowski/ExcelORM</RepositoryUrl>
         <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@@ -14,8 +14,7 @@
 	<Authors>Piotr Czajkowski</Authors>
 	<Description>Simple library to read/write C# objects from/to Excel files. </Description>
 	<RepositoryType>GitHub</RepositoryType>
-	<PackageReleaseNotes>Ability to start writing from given row.
-Trying to handle dates saved as text without throwing.</PackageReleaseNotes>
+	<PackageReleaseNotes>Few cosmetic changes.</PackageReleaseNotes>
     </PropertyGroup>
 
     <ItemGroup>

+ 11 - 1
ExcelORM/ExcelORM/Models/DynamicCell.cs

@@ -7,7 +7,17 @@ namespace ExcelORM.Models
         public int Position { get; set; }
         public string? Header { get; set; }
         public Type? Type { get; set; }
-        public object? Value { get; set; }
+
+        private object? value;
+        public object? Value
+        {
+            get => value;
+            set
+            {
+                this.value = value;
+                Type = value?.GetType();
+            }
+        }
 
         public static List<DynamicCell>? MapHeader(IXLCells? headerCells)
         {

+ 4 - 4
ExcelORM/ExcelORMTests/DynamicReaderTests.cs

@@ -26,10 +26,10 @@ public class DynamicReaderTests
 
         var first = results.First();
         Assert.Equal(typeof(string), first[0].Type);
-        Assert.Equal(typeof(DateTime?), first[1].Type);
-        Assert.Equal(typeof(TimeSpan?), first[2].Type);
-        Assert.Equal(typeof(double?), first[3].Type);
-        Assert.Equal(typeof(double?), first[4].Type);
+        Assert.Equal(typeof(DateTime), first[1].Type);
+        Assert.Equal(typeof(TimeSpan), first[2].Type);
+        Assert.Equal(typeof(double), first[3].Type);
+        Assert.Equal(typeof(double), first[4].Type);
     }
 
     [Fact]