Skip to content

Fixup for net9 SDK build #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ dotnet_diagnostic.RS2008.severity = none

# IDE0290: Use primary constructor
dotnet_diagnostic.IDE0290.severity = none

# CA1860: Avoid IEnumerable<T>.Count()
dotnet_diagnostic.CA1860.severity = none
3 changes: 2 additions & 1 deletion .github/workflows/dotnet-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ jobs:
with:
dotnet-version: |
6.0.x
8.0.x
8.0.x
9.0.x

- name: Build
run: dotnet build Dapper.AOT.sln -c Debug
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
dotnet-version: |
6.0.x
8.0.x
9.0.x

- uses: dotnet/nbgv@master
with:
Expand All @@ -37,8 +38,11 @@ jobs:
- name: Build
run: dotnet build Build.csproj --no-restore -c Release

- name: Test
run: dotnet test Build.csproj --no-build --verbosity normal -c Release -f net6.0 --filter FullyQualifiedName!~Integration
- name: Test .NET 8
run: dotnet test Build.csproj --no-build --verbosity normal -c Release -f net8.0 --filter FullyQualifiedName!~Integration

- name: Test .NET 9
run: dotnet test Build.csproj --no-build --verbosity normal -c Release -f net9.0 --filter FullyQualifiedName!~Integration

- name: Pack
if: ${{ success() && !github.base_ref }}
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<LangVersion>preview</LangVersion>
<Features>($Features);strict</Features>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)Dapper.png" Visible="false">
Expand Down
46 changes: 23 additions & 23 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
<Project>
<!--<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Packages.props, $(MSBuildThisFileDirectory)..))" />..-->
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.13.10" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="FastMember" Version="1.5.0" />
<PackageVersion Include="Dapper" Version="2.1.21" />
<PackageVersion Include="Dapper.AOT" Version="1.0.14" />
<PackageVersion Include="Dapper.StrongName" Version="2.1.21" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.6.133" />
<PackageVersion Include="Npgsql" Version="7.0.6" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageVersion Include="Microsoft.Build" Version="17.7.2" />
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.7.2" />
<PackageVersion Include="Dapper" Version="2.1.66" />
<PackageVersion Include="Dapper.AOT" Version="1.0.31" />
<PackageVersion Include="Dapper.StrongName" Version="2.1.66" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
<PackageVersion Include="Npgsql" Version="9.0.2" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.1" />
<PackageVersion Include="Microsoft.Build" Version="17.12.6" />
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.12.6" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
<!-- 4.8 would be nice, but: let's try to offer down-level compiler support -->
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="[4.4.0]" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Analyzer.Testing.XUnit" Version="1.1.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing.XUnit" Version="1.1.1" />
<!-- 4.8 would be nice, but: let's try to offer down-level compiler support -->
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="[4.4.0]" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.1.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="Microsoft.SqlServer.TransactSql.ScriptDom" Version="161.8910.0" />
<PackageVersion Include="Oracle.ManagedDataAccess" Version="21.12.0" />
<PackageVersion Include="Oracle.ManagedDataAccess.Core" Version="3.21.120" />
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.SqlServer.TransactSql.ScriptDom" Version="170.23.0" />
<PackageVersion Include="Oracle.ManagedDataAccess" Version="23.7.0" />
<PackageVersion Include="Oracle.ManagedDataAccess.Core" Version="23.7.0" />
<PackageVersion Include="System.Collections.Immutable" Version="9.0.1" />
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageVersion Include="System.Data.Common" Version="4.3.0" />
<PackageVersion Include="System.Data.SqlClient" Version="4.8.5" />
<PackageVersion Include="System.Memory" Version="4.5.5" />
<PackageVersion Include="Testcontainers.MsSql" Version="3.10.0" />
<PackageVersion Include="Testcontainers.PostgreSql" Version="3.6.0" />
<PackageVersion Include="System.Data.SqlClient" Version="4.9.0" />
<PackageVersion Include="System.Memory" Version="4.6.0" />
<PackageVersion Include="Testcontainers.MsSql" Version="4.1.0" />
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.1.0" />
<!-- these are bound by Microsoft.CodeAnalysis.CSharp.*.Testing.XUnit -->
<PackageVersion Include="xunit" Version="[2.3.0]" />
<PackageVersion Include="xunit.runner.visualstudio" Version="[2.3.0]" />
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"version": "9.0.102",
"rollForward": "latestMajor"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,11 @@ static string BuildParameterMap(in ParseState ctx, IInvocationOperation op, stri

internal static class FeatureKeys
{
public const string InterceptorsPreviewNamespaces = nameof(InterceptorsPreviewNamespaces),
public const string InterceptorsNamespaces = nameof(InterceptorsNamespaces),
InterceptorsPreviewNamespaces = nameof(InterceptorsPreviewNamespaces),
CodegenNamespace = "Dapper.AOT";
public static KeyValuePair<string, string> InterceptorsPreviewNamespacePair => new(InterceptorsPreviewNamespaces, CodegenNamespace);
public static KeyValuePair<string, string> InterceptorsNamespacePair => new(InterceptorsNamespaces, CodegenNamespace);
}

private static bool CheckPrerequisites(in GenerateState ctx)
Expand Down
24 changes: 24 additions & 0 deletions src/Dapper.AOT/CommandT.Batch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Data;
using System.Data.Common;
using System.Diagnostics;
using System.Linq;
Expand Down Expand Up @@ -222,6 +223,7 @@ private int ExecuteMultiBatch(ReadOnlySpan<TArgs> source, int batchSize) // TODO
{
Debug.Assert(source.Length > 1);
UnifiedCommand batch = default;
bool closeConnection = false;
try
{
foreach (var arg in source)
Expand All @@ -231,6 +233,12 @@ private int ExecuteMultiBatch(ReadOnlySpan<TArgs> source, int batchSize) // TODO
}
if (!batch.HasBatch) return 0;

if (connection.State != ConnectionState.Open)
{
connection.Open();
closeConnection = true;
}

var result = batch.AssertBatch.ExecuteNonQuery();

if (commandFactory.RequirePostProcess)
Expand All @@ -241,9 +249,14 @@ private int ExecuteMultiBatch(ReadOnlySpan<TArgs> source, int batchSize) // TODO
}
finally
{
if (closeConnection)
{
connection.Close();
}
batch.Cleanup();
}
}

private int ExecuteMultiBatch(IEnumerable<TArgs> source, int batchSize) // TODO: sub-batching
{
if (commandFactory.RequirePostProcess)
Expand All @@ -253,6 +266,7 @@ private int ExecuteMultiBatch(IEnumerable<TArgs> source, int batchSize) // TODO:
}

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

if (connection.State != ConnectionState.Open)
{
connection.Open();
closeConnection = true;
}

var result = batch.AssertBatch.ExecuteNonQuery();
if (commandFactory.RequirePostProcess)
{
Expand All @@ -271,6 +291,10 @@ private int ExecuteMultiBatch(IEnumerable<TArgs> source, int batchSize) // TODO:
}
finally
{
if (closeConnection)
{
connection.Close();
}
batch.Cleanup();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Dapper.AOT/Internal/SyncCommandState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private void OnBeforeExecute(DbCommand command)
Debug.Assert(command?.Connection is not null);
Command = command!;
connection = command!.Connection;

if (connection.State != ConnectionState.Open)
{
connection.Open();
Expand Down
4 changes: 3 additions & 1 deletion src/Dapper.AOT/UnifiedCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace Dapper;
Expand All @@ -16,8 +18,8 @@ namespace Dapper;
#pragma warning restore IDE0079

public readonly struct UnifiedCommand

{

/// <summary>
/// The <see cref="System.Data.Common.DbCommand"/> associated with the current operation; this may be <c>null</c> for batch commands.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<RootNamespace>Dapper.AOT.Test.Integration.Executables</RootNamespace>
<NoWarn>$(NoWarn);CS8002</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dapper" Condition="'$(TargetFramework)' == 'net8.0'" />
<PackageReference Include="Dapper" Condition="'$(TargetFramework)' == 'net6.0'" />
<PackageReference Include="Dapper.StrongName" Condition="'$(TargetFramework)'=='net48'" />
<PackageReference Include="Dapper" Condition="'$(TargetFramework)' == 'net8.0'" />

<ProjectReference Include="..\..\src\Dapper.AOT.Analyzers\Dapper.AOT.Analyzers.csproj" />
<ProjectReference Include="..\..\src\Dapper.AOT\Dapper.AOT.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<NoWarn>$(NoWarn);CS8002</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public abstract class IntegrationTestsBase
.WithFeatures(new[]
{
new KeyValuePair<string, string>("InterceptorsPreviewNamespaces", "$(InterceptorsPreviewNamespaces);Dapper.AOT"),
new KeyValuePair<string, string>("InterceptorsNamespaces", "$(InterceptorsNamespaces);Dapper.AOT"),
});

protected readonly IDbConnection DbConnection;
Expand Down
32 changes: 18 additions & 14 deletions test/Dapper.AOT.Test/Dapper.AOT.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net48</TargetFrameworks>
<TargetFrameworks>net8.0;net48;net9.0</TargetFrameworks>
<NoWarn>$(NoWarn);IDE0042;CS8002;CA1816</NoWarn>
<RootNamespace>Dapper.AOT.Test</RootNamespace>
<DefineConstants>$(DefineConstants);DAPPERAOT_INTERNAL</DefineConstants>
Expand All @@ -23,23 +23,19 @@
<None Update="**/*.output.netfx.*">
<DependentUpon>$([System.String]::Copy(%(Filename)).Replace('.output.netfx', '.input.cs'))</DependentUpon>
</None>
<None Update="**/*DAP*.*.cs*">
<DependentUpon>$([System.String]::Copy(%(Filename)).Replace('.VB.cs', '.cs'))</DependentUpon>
</None>
<None Update="**/*DAP*.*.cs*">
<DependentUpon>$([System.String]::Copy(%(Filename)).Replace('.VB.cs', '.cs'))</DependentUpon>
</None>

</ItemGroup>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Dapper" Condition="'$(TargetFramework)'!='net48'" />
<PackageReference Include="Dapper.StrongName" Condition="'$(TargetFramework)'=='net48'" />
<PackageReference Include="System.ComponentModel.Annotations" Condition="'$(TargetFramework)'=='net48'" />
<PackageReference Include="Microsoft.Build" Condition="'$(TargetFramework)'!='net6.0'" />
<PackageReference Include="Microsoft.Build" VersionOverride="17.10.4" Condition="'$(TargetFramework)'=='net6.0'" />
<PackageReference Include="Microsoft.Build" Condition="'$(TargetFramework)'!='net8.0'" />
<PackageReference Include="Microsoft.Build" VersionOverride="17.11.4" Condition="'$(TargetFramework)'=='net8.0'" />
<PackageReference Include="Microsoft.Build.Utilities.Core" />
<PackageReference Include="Npgsql" />
<PackageReference Include="Oracle.ManagedDataAccess" Condition="'$(TargetFramework)'=='net48'" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Condition="'$(TargetFramework)'!='net48'" />
<PackageReference Include="System.ComponentModel.Annotations" />
<PackageReference Include="System.Data.Common" />
<PackageReference Include="System.Data.SqlClient" />
<PackageReference Include="Microsoft.Data.SqlClient" />
<PackageReference Include="xunit" />
Expand All @@ -48,17 +44,25 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" />

<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Analyzer.Testing.XUnit" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing.XUnit" />
<PackageReference Include="Testcontainers.PostgreSql" />
<PackageReference Include="Testcontainers.MsSql" />
<PackageReference Include="Testcontainers.MsSql" />
</ItemGroup>


<ItemGroup Condition="'$(TargetFramework)'!='net48'">
<PackageReference Include="Npgsql" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net48'">
<PackageReference Include="Npgsql" VersionOverride="8.0.6" />
<PackageReference Include="System.Data.Common" />
<PackageReference Include="System.ComponentModel.Annotations" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../src/Dapper.AOT.Analyzers/Dapper.AOT.Analyzers.csproj" />
<ProjectReference Include="../../src/Dapper.AOT/Dapper.AOT.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions test/Dapper.AOT.Test/DapperApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public void DiscoveredMethodsAreExpected()
var names = string.Join(",", methods);
Log.WriteLine(names);

Assert.Equal("AsList<,AsTableValuedParameter,AsTableValuedParameter<,Execute,ExecuteAsync,ExecuteReader,ExecuteReaderAsync,ExecuteScalar,ExecuteScalar<,ExecuteScalarAsync,ExecuteScalarAsync<,GetRowParser,GetRowParser<,GetTypeName,Parse,Parse<,Query,Query<,QueryAsync,QueryAsync<,QueryFirst,QueryFirst<,QueryFirstAsync,QueryFirstAsync<,QueryFirstOrDefault,QueryFirstOrDefault<,QueryFirstOrDefaultAsync,QueryFirstOrDefaultAsync<,QueryMultiple,QueryMultipleAsync,QuerySingle,QuerySingle<,QuerySingleAsync,QuerySingleAsync<,QuerySingleOrDefault,QuerySingleOrDefault<,QuerySingleOrDefaultAsync,QuerySingleOrDefaultAsync<" + (IsNetFx ? "" : ",QueryUnbufferedAsync,QueryUnbufferedAsync<") + ",ReplaceLiterals,SetTypeName", names);
Assert.Equal("AsList<,AsTableValuedParameter,AsTableValuedParameter<,Execute,ExecuteAsync,ExecuteReader,ExecuteReaderAsync,ExecuteScalar,ExecuteScalar<,ExecuteScalarAsync,ExecuteScalarAsync<,GetRowParser,GetRowParser<,GetTypeName,Parse,Parse<,Query,Query<,QueryAsync,QueryAsync<,QueryFirst,QueryFirst<,QueryFirstAsync,QueryFirstAsync<,QueryFirstOrDefault,QueryFirstOrDefault<,QueryFirstOrDefaultAsync,QueryFirstOrDefaultAsync<,QueryMultiple,QueryMultipleAsync,QuerySingle,QuerySingle<,QuerySingleAsync,QuerySingleAsync<,QuerySingleOrDefault,QuerySingleOrDefault<,QuerySingleOrDefaultAsync,QuerySingleOrDefaultAsync<,QueryUnbufferedAsync,QueryUnbufferedAsync<,ReplaceLiterals,SetTypeName", names);

var candidates = string.Join(",", methods.Where(DapperInterceptorGenerator.IsCandidate));
Log.WriteLine(candidates);
Assert.Equal("Execute,ExecuteAsync,ExecuteReader,ExecuteReaderAsync,ExecuteScalar,ExecuteScalar<,ExecuteScalarAsync,ExecuteScalarAsync<,GetRowParser,GetRowParser<,Query,Query<,QueryAsync,QueryAsync<,QueryFirst,QueryFirst<,QueryFirstAsync,QueryFirstAsync<,QueryFirstOrDefault,QueryFirstOrDefault<,QueryFirstOrDefaultAsync,QueryFirstOrDefaultAsync<,QueryMultiple,QueryMultipleAsync,QuerySingle,QuerySingle<,QuerySingleAsync,QuerySingleAsync<,QuerySingleOrDefault,QuerySingleOrDefault<,QuerySingleOrDefaultAsync,QuerySingleOrDefaultAsync<" + (IsNetFx ? "" : ",QueryUnbufferedAsync,QueryUnbufferedAsync<"), candidates);
Assert.Equal("Execute,ExecuteAsync,ExecuteReader,ExecuteReaderAsync,ExecuteScalar,ExecuteScalar<,ExecuteScalarAsync,ExecuteScalarAsync<,GetRowParser,GetRowParser<,Query,Query<,QueryAsync,QueryAsync<,QueryFirst,QueryFirst<,QueryFirstAsync,QueryFirstAsync<,QueryFirstOrDefault,QueryFirstOrDefault<,QueryFirstOrDefaultAsync,QueryFirstOrDefaultAsync<,QueryMultiple,QueryMultipleAsync,QuerySingle,QuerySingle<,QuerySingleAsync,QuerySingleAsync<,QuerySingleOrDefault,QuerySingleOrDefault<,QuerySingleOrDefaultAsync,QuerySingleOrDefaultAsync<,QueryUnbufferedAsync,QueryUnbufferedAsync<", candidates);
}
}
Loading