Skip to content

Commit 7566e7d

Browse files
authored
Fixup for net9 SDK build (#144)
* lib refresh and fixup * more fixups * add 9.0.x to yml and test setup * test .net 8/9
1 parent 25203a3 commit 7566e7d

35 files changed

+494
-101
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ dotnet_diagnostic.RS2008.severity = none
55

66
# IDE0290: Use primary constructor
77
dotnet_diagnostic.IDE0290.severity = none
8+
9+
# CA1860: Avoid IEnumerable<T>.Count()
10+
dotnet_diagnostic.CA1860.severity = none

.github/workflows/dotnet-integration.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ jobs:
2222
with:
2323
dotnet-version: |
2424
6.0.x
25-
8.0.x
25+
8.0.x
26+
9.0.x
2627
2728
- name: Build
2829
run: dotnet build Dapper.AOT.sln -c Debug

.github/workflows/dotnet.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
dotnet-version: |
2424
6.0.x
2525
8.0.x
26+
9.0.x
2627
2728
- uses: dotnet/nbgv@master
2829
with:
@@ -37,8 +38,11 @@ jobs:
3738
- name: Build
3839
run: dotnet build Build.csproj --no-restore -c Release
3940

40-
- name: Test
41-
run: dotnet test Build.csproj --no-build --verbosity normal -c Release -f net6.0 --filter FullyQualifiedName!~Integration
41+
- name: Test .NET 8
42+
run: dotnet test Build.csproj --no-build --verbosity normal -c Release -f net8.0 --filter FullyQualifiedName!~Integration
43+
44+
- name: Test .NET 9
45+
run: dotnet test Build.csproj --no-build --verbosity normal -c Release -f net9.0 --filter FullyQualifiedName!~Integration
4246

4347
- name: Pack
4448
if: ${{ success() && !github.base_ref }}

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<LangVersion>preview</LangVersion>
2828
<Features>($Features);strict</Features>
2929
<EnableNETAnalyzers>true</EnableNETAnalyzers>
30+
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
3031
</PropertyGroup>
3132
<ItemGroup>
3233
<None Include="$(MSBuildThisFileDirectory)Dapper.png" Visible="false">

Directory.Packages.props

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
<Project>
22
<!--<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Packages.props, $(MSBuildThisFileDirectory)..))" />..-->
33
<ItemGroup>
4-
<PackageVersion Include="BenchmarkDotNet" Version="0.13.10" />
4+
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
55
<PackageVersion Include="FastMember" Version="1.5.0" />
6-
<PackageVersion Include="Dapper" Version="2.1.21" />
7-
<PackageVersion Include="Dapper.AOT" Version="1.0.14" />
8-
<PackageVersion Include="Dapper.StrongName" Version="2.1.21" />
9-
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.6.133" />
10-
<PackageVersion Include="Npgsql" Version="7.0.6" />
11-
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
12-
<PackageVersion Include="Microsoft.Build" Version="17.7.2" />
13-
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.7.2" />
6+
<PackageVersion Include="Dapper" Version="2.1.66" />
7+
<PackageVersion Include="Dapper.AOT" Version="1.0.31" />
8+
<PackageVersion Include="Dapper.StrongName" Version="2.1.66" />
9+
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
10+
<PackageVersion Include="Npgsql" Version="9.0.2" />
11+
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.1" />
12+
<PackageVersion Include="Microsoft.Build" Version="17.12.6" />
13+
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.12.6" />
1414
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="1.1.1" />
1515
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.1.1" />
16-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
16+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
1717
<!-- 4.8 would be nice, but: let's try to offer down-level compiler support -->
1818
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="[4.4.0]" />
1919
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Analyzer.Testing.XUnit" Version="1.1.1" />
2020
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing.XUnit" Version="1.1.1" />
2121
<!-- 4.8 would be nice, but: let's try to offer down-level compiler support -->
2222
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="[4.4.0]" />
23-
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.1.2" />
24-
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
25-
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
26-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
27-
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
28-
<PackageVersion Include="Microsoft.SqlServer.TransactSql.ScriptDom" Version="161.8910.0" />
29-
<PackageVersion Include="Oracle.ManagedDataAccess" Version="21.12.0" />
30-
<PackageVersion Include="Oracle.ManagedDataAccess.Core" Version="3.21.120" />
31-
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
23+
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.0.1" />
24+
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
25+
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.1" />
26+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
27+
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
28+
<PackageVersion Include="Microsoft.SqlServer.TransactSql.ScriptDom" Version="170.23.0" />
29+
<PackageVersion Include="Oracle.ManagedDataAccess" Version="23.7.0" />
30+
<PackageVersion Include="Oracle.ManagedDataAccess.Core" Version="23.7.0" />
31+
<PackageVersion Include="System.Collections.Immutable" Version="9.0.1" />
3232
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
3333
<PackageVersion Include="System.Data.Common" Version="4.3.0" />
34-
<PackageVersion Include="System.Data.SqlClient" Version="4.8.5" />
35-
<PackageVersion Include="System.Memory" Version="4.5.5" />
36-
<PackageVersion Include="Testcontainers.MsSql" Version="3.10.0" />
37-
<PackageVersion Include="Testcontainers.PostgreSql" Version="3.6.0" />
34+
<PackageVersion Include="System.Data.SqlClient" Version="4.9.0" />
35+
<PackageVersion Include="System.Memory" Version="4.6.0" />
36+
<PackageVersion Include="Testcontainers.MsSql" Version="4.1.0" />
37+
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.1.0" />
3838
<!-- these are bound by Microsoft.CodeAnalysis.CSharp.*.Testing.XUnit -->
3939
<PackageVersion Include="xunit" Version="[2.3.0]" />
4040
<PackageVersion Include="xunit.runner.visualstudio" Version="[2.3.0]" />

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.100",
3+
"version": "9.0.102",
44
"rollForward": "latestMajor"
55
}
66
}

src/Dapper.AOT.Analyzers/CodeAnalysis/DapperInterceptorGenerator.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,11 @@ static string BuildParameterMap(in ParseState ctx, IInvocationOperation op, stri
212212

213213
internal static class FeatureKeys
214214
{
215-
public const string InterceptorsPreviewNamespaces = nameof(InterceptorsPreviewNamespaces),
215+
public const string InterceptorsNamespaces = nameof(InterceptorsNamespaces),
216+
InterceptorsPreviewNamespaces = nameof(InterceptorsPreviewNamespaces),
216217
CodegenNamespace = "Dapper.AOT";
217218
public static KeyValuePair<string, string> InterceptorsPreviewNamespacePair => new(InterceptorsPreviewNamespaces, CodegenNamespace);
219+
public static KeyValuePair<string, string> InterceptorsNamespacePair => new(InterceptorsNamespaces, CodegenNamespace);
218220
}
219221

220222
private static bool CheckPrerequisites(in GenerateState ctx)

src/Dapper.AOT/CommandT.Batch.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Collections.Immutable;
5+
using System.Data;
56
using System.Data.Common;
67
using System.Diagnostics;
78
using System.Linq;
@@ -222,6 +223,7 @@ private int ExecuteMultiBatch(ReadOnlySpan<TArgs> source, int batchSize) // TODO
222223
{
223224
Debug.Assert(source.Length > 1);
224225
UnifiedCommand batch = default;
226+
bool closeConnection = false;
225227
try
226228
{
227229
foreach (var arg in source)
@@ -231,6 +233,12 @@ private int ExecuteMultiBatch(ReadOnlySpan<TArgs> source, int batchSize) // TODO
231233
}
232234
if (!batch.HasBatch) return 0;
233235

236+
if (connection.State != ConnectionState.Open)
237+
{
238+
connection.Open();
239+
closeConnection = true;
240+
}
241+
234242
var result = batch.AssertBatch.ExecuteNonQuery();
235243

236244
if (commandFactory.RequirePostProcess)
@@ -241,9 +249,14 @@ private int ExecuteMultiBatch(ReadOnlySpan<TArgs> source, int batchSize) // TODO
241249
}
242250
finally
243251
{
252+
if (closeConnection)
253+
{
254+
connection.Close();
255+
}
244256
batch.Cleanup();
245257
}
246258
}
259+
247260
private int ExecuteMultiBatch(IEnumerable<TArgs> source, int batchSize) // TODO: sub-batching
248261
{
249262
if (commandFactory.RequirePostProcess)
@@ -253,6 +266,7 @@ private int ExecuteMultiBatch(IEnumerable<TArgs> source, int batchSize) // TODO:
253266
}
254267

255268
UnifiedCommand batch = default;
269+
bool closeConnection = false;
256270
try
257271
{
258272
foreach (var arg in source)
@@ -262,6 +276,12 @@ private int ExecuteMultiBatch(IEnumerable<TArgs> source, int batchSize) // TODO:
262276
}
263277
if (!batch.HasBatch) return 0;
264278

279+
if (connection.State != ConnectionState.Open)
280+
{
281+
connection.Open();
282+
closeConnection = true;
283+
}
284+
265285
var result = batch.AssertBatch.ExecuteNonQuery();
266286
if (commandFactory.RequirePostProcess)
267287
{
@@ -271,6 +291,10 @@ private int ExecuteMultiBatch(IEnumerable<TArgs> source, int batchSize) // TODO:
271291
}
272292
finally
273293
{
294+
if (closeConnection)
295+
{
296+
connection.Close();
297+
}
274298
batch.Cleanup();
275299
}
276300
}

src/Dapper.AOT/Internal/SyncCommandState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private void OnBeforeExecute(DbCommand command)
3838
Debug.Assert(command?.Connection is not null);
3939
Command = command!;
4040
connection = command!.Connection;
41-
41+
4242
if (connection.State != ConnectionState.Open)
4343
{
4444
connection.Open();

src/Dapper.AOT/UnifiedCommand.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using System.Collections.Generic;
33
using System.Data;
44
using System.Data.Common;
5+
using System.Diagnostics.CodeAnalysis;
6+
using System.Diagnostics;
57
using System.Runtime.CompilerServices;
68

79
namespace Dapper;
@@ -16,8 +18,8 @@ namespace Dapper;
1618
#pragma warning restore IDE0079
1719

1820
public readonly struct UnifiedCommand
19-
2021
{
22+
2123
/// <summary>
2224
/// The <see cref="System.Data.Common.DbCommand"/> associated with the current operation; this may be <c>null</c> for batch commands.
2325
/// </summary>

0 commit comments

Comments
 (0)