Skip to content

Commit

Permalink
Upgrade dotnet to v8.0 and upgrade C# dependencies (#3334)
Browse files Browse the repository at this point in the history
- Upgrading to Latest Dotnet version for test framework also upgrading to `Microsoft.Data.SqlClient` driver from `System.Data.SqlClient` as it is deprecated check [link](https://techcommunity.microsoft.com/blog/sqlserver/announcement-system-data-sqlclient-package-is-now-deprecated/4227205)

- Also upgraded other packages being used to latest versions

Couple of changes for migrating to newer driver
1. Add a new switch in config called `runInRegression` to turn off encryption for sqlclient driver as its by default on in the new Package , For More Context check [link](https://github.com/dotnet/SqlClient/blob/main/porting-cheat-sheet.md)

2. Add a appcontext switch to avoid rounding on decimals instead of truncation. More details dotnet/SqlClient#2905 


Signed-off-by: Nirmit Shah [[email protected]](mailto:[email protected])
  • Loading branch information
shah-nirmit authored Dec 31, 2024
1 parent fd5eca1 commit 8931d86
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/composite-actions/install-and-run-dotnet/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ runs:
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get install -y apt-transport-https
sudo apt-get install -y dotnet-sdk-5.0
sudo apt-get install -y dotnet-sdk-8.0
sudo apt-get install -y apt-transport-https
sudo apt-get install -y aspnetcore-runtime-5.0
sudo apt-get install -y aspnetcore-runtime-8.0
shell: bash

- name: Run Dotnet Tests
Expand Down
1 change: 1 addition & 0 deletions test/dotnet/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ bcpPath=/usr/local/bin/bcp

runInParallel = false
printToConsole = true
runInRegression = true

driver = sql
provider = SQL NATIVE CLIENT
Expand Down
22 changes: 11 additions & 11 deletions test/dotnet/dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="System.Data.OleDb" Version="5.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="Microsoft.SqlServer.Types" Version="7.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Serilog" Version="4.2.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="System.Data.OleDb" Version="9.0.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="Microsoft.SqlServer.Types" Version="160.1000.6" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.console" Version="2.4.1">
<PackageReference Include="xunit.runner.console" Version="2.9.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="MathNet.Numerics" Version="4.15.0" />
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion test/dotnet/src/BatchRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
using System.IO;
using Serilog;

Expand Down
1 change: 1 addition & 0 deletions test/dotnet/src/ExecuteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ IEnumerable<FileInfo> GetFilesByExtensions(DirectoryInfo dir, String[] noExecTes
[Fact]
public void Test()
{
AppContext.SetSwitch("Switch.Microsoft.Data.SqlClient.TruncateScaledDecimal", true);
BatchRun batchRun = new BatchRun();
DirectoryInfo dir = new DirectoryInfo(ConfigSetup.QueryFolder);
IEnumerable<FileInfo> allFiles;
Expand Down
2 changes: 1 addition & 1 deletion test/dotnet/src/PrepareExecBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Data;
using System.Data.Common;
using System.Data.OleDb;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Types;
using System.IO;
Expand Down
8 changes: 6 additions & 2 deletions test/dotnet/utils/ConfigSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static class ConfigSetup
public static readonly string TestName = Dictionary["testName"];
public static readonly bool RunInParallel = bool.Parse(Dictionary["runInParallel"]);
public static readonly bool PrintToConsole = bool.Parse(Dictionary["printToConsole"]);
public static bool RunInRegression;
public static string Database;
public static string Provider = Dictionary["provider"];

Expand Down Expand Up @@ -42,6 +43,7 @@ public static Dictionary<string, string> LoadConfig()
}
Database = dictionary["driver"];
Provider = dictionary["provider"];
RunInRegression = bool.Parse(dictionary["runInRegression"]);

/* Creating Server Connection String and Query. */
dictionary["bblConnectionString"] = BuildConnectionString(dictionary["babel_URL"], dictionary["babel_port"],
Expand All @@ -58,8 +60,10 @@ static string BuildConnectionString(string url, string port, string db, string u
return @"Provider = " + ConfigSetup.Provider + ";Data Source = " + url + "," + port + "; Initial Catalog = " + db
+ "; User ID = " + uid + "; Password = " + pwd + ";";
case "sql":
return @"Data Source = " + url + "," + port + "; Initial Catalog = " + db
+ "; User ID = " + uid + "; Password = " + pwd + ";";
string baseConnectionString = $"Data Source={url},{port};Initial Catalog={db};User ID={uid};Password={pwd};";
return ConfigSetup.RunInRegression
? $"{baseConnectionString};Encrypt=false"
: baseConnectionString;
default:
throw new Exception("Driver Not Supported");
}
Expand Down
4 changes: 2 additions & 2 deletions test/dotnet/utils/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
using System.Data;
using System.Data.Common;
using System.Data.OleDb;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
using System.Data.SqlTypes;
using System.Diagnostics;
using System.IO;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
using Microsoft.SqlServer.Server;
using Microsoft.Data.SqlClient.Server;
using Serilog;
using Serilog.Core;
using Xunit;
Expand Down

0 comments on commit 8931d86

Please sign in to comment.