diff --git a/.github/workflows/BuildAndTestOnEveryPush.yml b/.github/workflows/BuildAndTestOnEveryPush.yml index 22207a3..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 @@ -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 diff --git a/Frends.Community.SQL.Tests/Frends.Community.SQL.Tests.csproj b/Frends.Community.SQL.Tests/Frends.Community.SQL.Tests.csproj index 5ff5ad9..678ae50 100644 --- a/Frends.Community.SQL.Tests/Frends.Community.SQL.Tests.csproj +++ b/Frends.Community.SQL.Tests/Frends.Community.SQL.Tests.csproj @@ -1,17 +1,17 @@  - net471 + net6.0 false - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs b/Frends.Community.SQL.Tests/SaveQueryToCSVTests.cs index 37d5085..b0e52e7 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; @@ -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"); @@ -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.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) diff --git a/Frends.Community.SQL.Tests/TestBulkInsert.cs b/Frends.Community.SQL.Tests/TestBulkInsert.cs index 03b29e6..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; @@ -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"; 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 @@ - + + - - + - 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. |