From 2f8ca98426c382edd12782ddb5f8291427af1172 Mon Sep 17 00:00:00 2001 From: Janne Pennanen Date: Thu, 12 Dec 2024 15:01:06 +0200 Subject: [PATCH 01/11] Added targets to .NET6 & 8, updated packages and made adjustments to code as needed after the updates. --- Frends.Community.SQL/Frends.Community.SQL.cs | 4 ++-- Frends.Community.SQL/Frends.Community.SQL.csproj | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Frends.Community.SQL/Frends.Community.SQL.cs b/Frends.Community.SQL/Frends.Community.SQL.cs index 5da9ead..4228de7 100644 --- a/Frends.Community.SQL/Frends.Community.SQL.cs +++ b/Frends.Community.SQL/Frends.Community.SQL.cs @@ -5,7 +5,7 @@ using System.ComponentModel; using System.Data; using System.Data.Common; -using System.Data.SqlClient; +using Microsoft.Data.SqlClient; using System.Globalization; using System.IO; using System.Linq; @@ -307,7 +307,7 @@ internal static int RowsCopiedCount(this SqlBulkCopy bulkCopy) const string rowsCopiedFieldName = "_rowsCopied"; FieldInfo rowsCopiedField = typeof(SqlBulkCopy).GetField(rowsCopiedFieldName, BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance); - return rowsCopiedField != null ? (int)rowsCopiedField.GetValue(bulkCopy) : 0; + return rowsCopiedField != null ? Convert.ToInt32(rowsCopiedField.GetValue(bulkCopy)) : 0; } } } diff --git a/Frends.Community.SQL/Frends.Community.SQL.csproj b/Frends.Community.SQL/Frends.Community.SQL.csproj index 48c3da8..0e1a786 100644 --- a/Frends.Community.SQL/Frends.Community.SQL.csproj +++ b/Frends.Community.SQL/Frends.Community.SQL.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net471 + netstandard2.0;net471;net6.0;net8.0 HiQ Finland HiQ Finland MIT @@ -9,7 +9,7 @@ true Frends true - 1.4.0 + 2.0.0 @@ -20,12 +20,11 @@ - + + - - + - From 81726ee86927a0d6269e2571671e39c29c2022e8 Mon Sep 17 00:00:00 2001 From: Janne Pennanen Date: Thu, 12 Dec 2024 15:01:18 +0200 Subject: [PATCH 02/11] Updated test packages as required --- Frends.Community.SQL.Tests/Frends.Community.SQL.Tests.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Frends.Community.SQL.Tests/Frends.Community.SQL.Tests.csproj b/Frends.Community.SQL.Tests/Frends.Community.SQL.Tests.csproj index 5ff5ad9..2e2b2d7 100644 --- a/Frends.Community.SQL.Tests/Frends.Community.SQL.Tests.csproj +++ b/Frends.Community.SQL.Tests/Frends.Community.SQL.Tests.csproj @@ -7,11 +7,11 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 4968934a6f4857609ec4f809fa43e4bb2bbf117e Mon Sep 17 00:00:00 2001 From: Janne Pennanen Date: Thu, 12 Dec 2024 15:02:02 +0200 Subject: [PATCH 03/11] Added TrustServerCertificate to test conn strings --- Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs | 2 +- Frends.Community.SQL.Tests/TestBulkInsert.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs b/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs index 37d5085..9d7bf57 100644 --- a/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs +++ b/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs @@ -27,7 +27,7 @@ winpty docker exec -it sql1 "bash" [TestFixture] class SaveQueryToCSVTests { - private static readonly string _connString = "Server=127.0.0.1,1433;Database=Master;User Id=SA;Password=Salakala123!"; + private static readonly string _connString = "Server=127.0.0.1,1433;Database=Master;User Id=SA;Password=Salakala123!;TrustServerCertificate=True"; private static readonly string _tableName = "TestTable"; private static readonly string _destination = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../TestData/test.csv"); diff --git a/Frends.Community.SQL.Tests/TestBulkInsert.cs b/Frends.Community.SQL.Tests/TestBulkInsert.cs index 03b29e6..a5812f3 100644 --- a/Frends.Community.SQL.Tests/TestBulkInsert.cs +++ b/Frends.Community.SQL.Tests/TestBulkInsert.cs @@ -30,7 +30,7 @@ docker exec -it sql1 "bash" GO */ - private readonly string ConnectionString = "Server=127.0.0.1,1433;Database=Master;User Id=SA;Password=Salakala123!"; + private readonly string ConnectionString = "Server=127.0.0.1,1433;Database=Master;User Id=SA;Password=Salakala123!;TrustServerCertificate=True"; // The test case creates and destroys an SQL table with this name. // Ensure that this table does not already exist in the DB! Test aborts if it does. private readonly string TableName = "FrendsTestTable"; From 442fd9dcd510a797abe4cac0d4d41d4d4d1a74d0 Mon Sep 17 00:00:00 2001 From: Janne Pennanen Date: Thu, 12 Dec 2024 15:02:10 +0200 Subject: [PATCH 04/11] Updated readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 349cae5..b89b9e6 100644 --- a/README.md +++ b/README.md @@ -138,3 +138,4 @@ NOTE: Be sure to merge the latest from "upstream" before making a pull request! | 1.2.0 | Added BulkInsertDataTable and related test. | | 1.3.0 | Added parameter AddQuotesToStrings to SaveQueryToCSVOptions which if disabled will not add quotes to string typed fields. | | 1.4.0 | Added result object SaveQueryToCSVResult with EntriesWritten, Path and FileName properties. Added option to pass custom field delimiter. Added support for binary datatypes. | +| 2.0.0 | Added targeting to .NET6 and .NET8. Updated the following packages: CsvHelper to v33.0.1 and System.Configuration.ConfigurationManager to 9.0.0. Replaced System.Data.SqlClient with Microsoft.Data.SqlClient, as the former is deprecated. Made small adjustments as required after package updates. | From 6892172ab2d5d64f26a45723cb7476d32938b673 Mon Sep 17 00:00:00 2001 From: Janne Pennanen Date: Thu, 12 Dec 2024 15:29:31 +0200 Subject: [PATCH 05/11] Updated test names in workflow, as they were outdated --- .github/workflows/BuildAndTestOnEveryPush.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/BuildAndTestOnEveryPush.yml b/.github/workflows/BuildAndTestOnEveryPush.yml index 22207a3..fc5b96b 100644 --- a/.github/workflows/BuildAndTestOnEveryPush.yml +++ b/.github/workflows/BuildAndTestOnEveryPush.yml @@ -21,7 +21,7 @@ jobs: run: dotnet build - name: Run SaveQueryToCsvTests - run: dotnet test --filter Frends.Community.SQL.Tests.SaveQueryToCsvTests + run: dotnet test --filter Frends.Community.SQL.Tests.SaveQueryToCSVTests - name: Run TestBulkInsert run: dotnet test --filter Frends.Community.SQL.Tests.TestBulkInsert @@ -38,7 +38,7 @@ jobs: run: dotnet build - name: Test - run: dotnet test --filter Frends.Community.SQL.Tests.SQLTaskTest + run: dotnet test --filter Frends.Community.SQL.Tests.SQLTest - name: Pack release version of task run: dotnet pack --configuration Release --include-source From 9a1efcd2f39c7a989080e4994ad2d72a4797009f Mon Sep 17 00:00:00 2001 From: Janne Pennanen Date: Mon, 13 Jan 2025 15:15:58 +0200 Subject: [PATCH 06/11] Removed test filter from test file --- .github/workflows/BuildAndTestOnEveryPush.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/BuildAndTestOnEveryPush.yml b/.github/workflows/BuildAndTestOnEveryPush.yml index fc5b96b..ff8d44a 100644 --- a/.github/workflows/BuildAndTestOnEveryPush.yml +++ b/.github/workflows/BuildAndTestOnEveryPush.yml @@ -38,7 +38,7 @@ jobs: run: dotnet build - name: Test - run: dotnet test --filter Frends.Community.SQL.Tests.SQLTest + run: dotnet test - name: Pack release version of task run: dotnet pack --configuration Release --include-source From 13a2a76f323b527c8923fdbe9b9e9bed154b2a30 Mon Sep 17 00:00:00 2001 From: Janne Pennanen Date: Mon, 13 Jan 2025 15:47:39 +0200 Subject: [PATCH 07/11] Added test filter back --- .github/workflows/BuildAndTestOnEveryPush.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/BuildAndTestOnEveryPush.yml b/.github/workflows/BuildAndTestOnEveryPush.yml index ff8d44a..fc5b96b 100644 --- a/.github/workflows/BuildAndTestOnEveryPush.yml +++ b/.github/workflows/BuildAndTestOnEveryPush.yml @@ -38,7 +38,7 @@ jobs: run: dotnet build - name: Test - run: dotnet test + run: dotnet test --filter Frends.Community.SQL.Tests.SQLTest - name: Pack release version of task run: dotnet pack --configuration Release --include-source From e7487a2064f772a52a9d93190a18aa0193210bbb Mon Sep 17 00:00:00 2001 From: Janne Pennanen Date: Wed, 22 Jan 2025 16:00:49 +0100 Subject: [PATCH 08/11] Targeted tests to .net6 and changed runner to ubuntu-20.04 --- .github/workflows/BuildAndTestOnEveryPush.yml | 2 +- Frends.Community.SQL.Tests/Frends.Community.SQL.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/BuildAndTestOnEveryPush.yml b/.github/workflows/BuildAndTestOnEveryPush.yml index fc5b96b..fa7e8b7 100644 --- a/.github/workflows/BuildAndTestOnEveryPush.yml +++ b/.github/workflows/BuildAndTestOnEveryPush.yml @@ -9,7 +9,7 @@ jobs: UbuntuBuild: name: Build on ubuntu-latest - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v1 diff --git a/Frends.Community.SQL.Tests/Frends.Community.SQL.Tests.csproj b/Frends.Community.SQL.Tests/Frends.Community.SQL.Tests.csproj index 2e2b2d7..678ae50 100644 --- a/Frends.Community.SQL.Tests/Frends.Community.SQL.Tests.csproj +++ b/Frends.Community.SQL.Tests/Frends.Community.SQL.Tests.csproj @@ -1,7 +1,7 @@  - net471 + net6.0 false From 0b407d9e9a1e92c1dc1f35b46f7501a246b7a1c4 Mon Sep 17 00:00:00 2001 From: Janne Pennanen Date: Wed, 22 Jan 2025 16:05:23 +0100 Subject: [PATCH 09/11] Fixed tests to also use Microsoft.Data.SqlClient --- Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs | 2 +- Frends.Community.SQL.Tests/TestBulkInsert.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs b/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs index 9d7bf57..1109b70 100644 --- a/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs +++ b/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs @@ -1,6 +1,6 @@ using System; using System.Data; -using System.Data.SqlClient; +using Microsoft.Data.SqlClient; using System.Threading.Tasks; using System.IO; using NUnit.Framework; diff --git a/Frends.Community.SQL.Tests/TestBulkInsert.cs b/Frends.Community.SQL.Tests/TestBulkInsert.cs index a5812f3..7314b8a 100644 --- a/Frends.Community.SQL.Tests/TestBulkInsert.cs +++ b/Frends.Community.SQL.Tests/TestBulkInsert.cs @@ -1,7 +1,7 @@ using NUnit.Framework; using System; using System.Collections.Generic; -using System.Data.SqlClient; +using Microsoft.Data.SqlClient; using System.Data; using System.Linq; using System.Threading; From e828d8589e6679654608bfb60859d2b6838b0560 Mon Sep 17 00:00:00 2001 From: Janne Pennanen Date: Wed, 22 Jan 2025 16:10:52 +0100 Subject: [PATCH 10/11] Test fixes --- Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs b/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs index 1109b70..8b6f611 100644 --- a/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs +++ b/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs @@ -169,7 +169,7 @@ public async Task SaveQueryToCSV_WithImageDBType() var output = File.ReadAllText(_destination); - Assert.AreEqual(BitConverter.ToString(File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(_destination), "Test_image.png"))), output.TrimEnd(Environment.NewLine.ToCharArray())); + Assert.AreEqual(BitConverter.ToString(File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(_destination), "Test_image.png"))), output); } [Test] @@ -202,7 +202,7 @@ public async Task SaveQueryToCSV_WithBinaryDBType() var output = File.ReadAllText(_destination); - Assert.AreEqual(BitConverter.ToString(File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(_destination), "Test_Text.txt"))), output.TrimEnd(Environment.NewLine.ToCharArray())); + Assert.AreEqual(BitConverter.ToString(File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(_destination), "Test_text.txt"))), output.TrimEnd(Environment.NewLine.ToCharArray())); } private static void InsertTestData(string commandText, SqlParameter[] parameters = null) From b54c02337fe3f1cb18a60ec74fba1cec3570244e Mon Sep 17 00:00:00 2001 From: Janne Pennanen Date: Wed, 22 Jan 2025 16:17:18 +0100 Subject: [PATCH 11/11] More test fixes --- Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs b/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs index 8b6f611..b0e52e7 100644 --- a/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs +++ b/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs @@ -169,7 +169,7 @@ public async Task SaveQueryToCSV_WithImageDBType() var output = File.ReadAllText(_destination); - Assert.AreEqual(BitConverter.ToString(File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(_destination), "Test_image.png"))), output); + Assert.AreEqual(BitConverter.ToString(File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(_destination), "Test_image.png"))), output.TrimEnd('\r', '\n')); } [Test] @@ -202,7 +202,7 @@ public async Task SaveQueryToCSV_WithBinaryDBType() var output = File.ReadAllText(_destination); - Assert.AreEqual(BitConverter.ToString(File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(_destination), "Test_text.txt"))), output.TrimEnd(Environment.NewLine.ToCharArray())); + Assert.AreEqual(BitConverter.ToString(File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(_destination), "Test_text.txt"))), output.TrimEnd('\r', '\n')); } private static void InsertTestData(string commandText, SqlParameter[] parameters = null)