From d07ede19501ebcfcdcb6ff38ba517381b7070833 Mon Sep 17 00:00:00 2001 From: Joe Gallagher Date: Wed, 19 Nov 2025 15:21:55 -0500 Subject: [PATCH 1/3] allow null table type rows --- src/Pingmint.CodeGen.Sql/CodeFile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingmint.CodeGen.Sql/CodeFile.cs b/src/Pingmint.CodeGen.Sql/CodeFile.cs index 952f946..52886a4 100644 --- a/src/Pingmint.CodeGen.Sql/CodeFile.cs +++ b/src/Pingmint.CodeGen.Sql/CodeFile.cs @@ -176,7 +176,7 @@ public String GenerateCode() code.Line("public {0}(List<{1}> rows) : base()", dataTableClassName, rowClassName); using (code.CreateBraceScope()) { - code.Line("ArgumentNullException.ThrowIfNull(rows);"); + code.Line("if (rows is null) { rows = []; }"); code.Line(); foreach (var col in record.Properties) { From 92ce4f72d491899ff869b081e49b25cd2b0a5af3 Mon Sep 17 00:00:00 2001 From: Joe Gallagher Date: Wed, 19 Nov 2025 15:58:59 -0500 Subject: [PATCH 2/3] nullable annotation --- src/Pingmint.CodeGen.Sql/CodeFile.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Pingmint.CodeGen.Sql/CodeFile.cs b/src/Pingmint.CodeGen.Sql/CodeFile.cs index 52886a4..c969e72 100644 --- a/src/Pingmint.CodeGen.Sql/CodeFile.cs +++ b/src/Pingmint.CodeGen.Sql/CodeFile.cs @@ -173,11 +173,9 @@ public String GenerateCode() using var tableClass = code.PartialClass("public sealed", dataTableClassName, "DataTable"); code.Line("public {0}() : this(new List<{1}>()) {{ }}", dataTableClassName, rowClassName); - code.Line("public {0}(List<{1}> rows) : base()", dataTableClassName, rowClassName); + code.Line("public {0}(List<{1}>? rows) : base()", dataTableClassName, rowClassName); using (code.CreateBraceScope()) { - code.Line("if (rows is null) { rows = []; }"); - code.Line(); foreach (var col in record.Properties) { var allowDbNull = col.ColumnIsNullable ? "true" : "false"; @@ -185,7 +183,7 @@ public String GenerateCode() var propertyTypeName = col.FieldTypeWithoutNullable; code.Line("base.Columns.Add(new DataColumn() {{ ColumnName = \"{0}\", DataType = typeof({1}), AllowDBNull = {2}{3} }});", col.ColumnName, propertyTypeName, allowDbNull, maxLength); } - using (code.ForEach("var row in rows")) + using (code.ForEach("var row in rows ?? []")) { var parameterBuilder = String.Empty; foreach (var col in record.Properties) From 511e505837b3005e7a79c367d81b42e45baed943 Mon Sep 17 00:00:00 2001 From: Joe Gallagher Date: Wed, 19 Nov 2025 16:18:04 -0500 Subject: [PATCH 3/3] bump version --- src/Pingmint.CodeGen.Sql/Pingmint.CodeGen.Sql.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pingmint.CodeGen.Sql/Pingmint.CodeGen.Sql.csproj b/src/Pingmint.CodeGen.Sql/Pingmint.CodeGen.Sql.csproj index a680669..29b6821 100644 --- a/src/Pingmint.CodeGen.Sql/Pingmint.CodeGen.Sql.csproj +++ b/src/Pingmint.CodeGen.Sql/Pingmint.CodeGen.Sql.csproj @@ -1,7 +1,7 @@ - 0.47 + 0.48 Exe net10.0 latest