Skip to content

Commit c4f0947

Browse files
authored
Merge branch 'main' into feature/reference-trimmer
2 parents 7887591 + 953f371 commit c4f0947

27 files changed

Lines changed: 461 additions & 232 deletions

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Setup dotnet
4444
uses: actions/setup-dotnet@v4
4545
with:
46-
dotnet-version: '9.0.x'
46+
dotnet-version: '10.0.x'
4747
- name: .NET Build
4848
run: dotnet build Build.csproj -c Release /p:CI=true
4949
- name: Dapper Tests

Dapper.SqlBuilder/SqlBuilder.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class SqlBuilder
1010
private readonly Dictionary<string, Clauses> _data = new Dictionary<string, Clauses>();
1111
private int _seq;
1212

13-
private class Clause
13+
private sealed class Clause
1414
{
1515
public Clause(string sql, object? parameters, bool isInclusive)
1616
{
@@ -23,7 +23,7 @@ public Clause(string sql, object? parameters, bool isInclusive)
2323
public bool IsInclusive { get; }
2424
}
2525

26-
private class Clauses : List<Clause>
26+
private sealed class Clauses : List<Clause>
2727
{
2828
private readonly string _joiner, _prefix, _postfix;
2929

@@ -36,11 +36,9 @@ public Clauses(string joiner, string prefix = "", string postfix = "")
3636

3737
public string ResolveClauses(DynamicParameters p)
3838
{
39-
foreach (var item in this)
40-
{
41-
p.AddDynamicParams(item.Parameters);
42-
}
43-
return this.Any(a => a.IsInclusive)
39+
ForEach(item => p.AddDynamicParams(item.Parameters));
40+
41+
return Exists(a => a.IsInclusive)
4442
? _prefix +
4543
string.Join(_joiner,
4644
this.Where(a => !a.IsInclusive)

Dapper.StrongName/Dapper.StrongName.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Title>Dapper (Strong Named)</Title>
66
<Description>A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite, SqlCE, Firebird etc. Major Sponsor: Dapper Plus from ZZZ Projects.</Description>
77
<Authors>Sam Saffron;Marc Gravell;Nick Craver</Authors>
8-
<TargetFrameworks>net461;netstandard2.0;net8.0</TargetFrameworks>
8+
<TargetFrameworks>net461;netstandard2.0;net8.0;net10.0</TargetFrameworks>
99
<SignAssembly>true</SignAssembly>
1010
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
1111
<Nullable>enable</Nullable>
@@ -19,10 +19,12 @@
1919

2020
<ItemGroup Condition=" '$(TargetFramework)' == 'net461'">
2121
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
22+
<PackageReference Include="System.Threading.Tasks.Extensions" />
2223
</ItemGroup>
2324

2425
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
2526
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
2627
<PackageReference Include="System.Reflection.Emit.Lightweight" />
28+
<PackageReference Include="System.Threading.Tasks.Extensions" />
2729
</ItemGroup>
2830
</Project>

Dapper.sln renamed to Dapper.sln.old

Lines changed: 121 additions & 121 deletions
Large diffs are not rendered by default.

Dapper.slnx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<Solution>
2+
<Folder Name="/docs/">
3+
<Project Path="docs/docs.csproj" />
4+
</Folder>
5+
<Folder Name="/Solution Items/">
6+
<File Path=".editorconfig" />
7+
<File Path=".github/workflows/main.yml" />
8+
<File Path="appveyor.yml" />
9+
<File Path="Build.csproj" />
10+
<File Path="build.ps1" />
11+
<File Path="Dapper.png" />
12+
<File Path="Directory.Build.props" />
13+
<File Path="Directory.Packages.props" />
14+
<File Path="docs/index.md" />
15+
<File Path="global.json" />
16+
<File Path="License.txt" />
17+
<File Path="NonCLA.md" />
18+
<File Path="nuget.config" />
19+
<File Path="Readme.md" />
20+
<File Path="version.json" />
21+
</Folder>
22+
<Folder Name="/src/">
23+
<Project Path="Dapper.EntityFramework.StrongName/Dapper.EntityFramework.StrongName.csproj" />
24+
<Project Path="Dapper.EntityFramework/Dapper.EntityFramework.csproj" />
25+
<Project Path="Dapper.ProviderTools/Dapper.ProviderTools.csproj" />
26+
<Project Path="Dapper.Rainbow/Dapper.Rainbow.csproj" />
27+
<Project Path="Dapper.SqlBuilder/Dapper.SqlBuilder.csproj" />
28+
<Project Path="Dapper.StrongName/Dapper.StrongName.csproj" />
29+
<Project Path="Dapper/Dapper.csproj" />
30+
</Folder>
31+
<Folder Name="/tests/">
32+
<File Path="tests/Directory.Build.props" />
33+
<File Path="tests/Directory.Build.targets" />
34+
<File Path="tests/docker-compose.yml" />
35+
<Project Path="benchmarks/Dapper.Tests.Performance/Dapper.Tests.Performance.csproj" />
36+
<Project Path="tests/Dapper.Tests/Dapper.Tests.csproj" />
37+
</Folder>
38+
</Solution>

Dapper/Dapper.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<PackageTags>orm;sql;micro-orm</PackageTags>
66
<Description>A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite, SqlCE, Firebird etc. Major Sponsor: Dapper Plus from ZZZ Projects.</Description>
77
<Authors>Sam Saffron;Marc Gravell;Nick Craver</Authors>
8-
<TargetFrameworks>net461;netstandard2.0;net8.0</TargetFrameworks>
8+
<TargetFrameworks>net461;netstandard2.0;net8.0;net10.0</TargetFrameworks>
99
<Nullable>enable</Nullable>
1010
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1111
</PropertyGroup>
@@ -26,10 +26,12 @@
2626

2727
<ItemGroup Condition=" '$(TargetFramework)' == 'net461'">
2828
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
29+
<PackageReference Include="System.Threading.Tasks.Extensions" />
2930
</ItemGroup>
3031

3132
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
3233
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
3334
<PackageReference Include="System.Reflection.Emit.Lightweight" />
35+
<PackageReference Include="System.Threading.Tasks.Extensions" />
3436
</ItemGroup>
3537
</Project>

Dapper/DefaultTypeMap.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Dapper
1010
/// </summary>
1111
public sealed class DefaultTypeMap : SqlMapper.ITypeMap
1212
{
13-
private readonly List<FieldInfo> _fields;
13+
private readonly FieldInfo[] _fields;
1414
private readonly Type _type;
1515

1616
/// <summary>
@@ -42,7 +42,7 @@ internal static MethodInfo GetPropertySetterOrThrow(PropertyInfo propertyInfo, T
4242
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
4343
Type.DefaultBinder,
4444
propertyInfo.PropertyType,
45-
propertyInfo.GetIndexParameters().Select(p => p.ParameterType).ToArray(),
45+
Array.ConvertAll(propertyInfo.GetIndexParameters(), p => p.ParameterType),
4646
null)!.GetSetMethod(true);
4747
}
4848

@@ -54,9 +54,9 @@ internal static List<PropertyInfo> GetSettableProps(Type t)
5454
.ToList();
5555
}
5656

57-
internal static List<FieldInfo> GetSettableFields(Type t)
57+
private static FieldInfo[] GetSettableFields(Type t)
5858
{
59-
return t.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).ToList();
59+
return t.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
6060
}
6161

6262
/// <summary>
@@ -156,20 +156,20 @@ public SqlMapper.IMemberMap GetConstructorParameter(ConstructorInfo constructor,
156156

157157
// preference order is:
158158
// exact match over underscore match, exact case over wrong case, backing fields over regular fields, match-inc-underscores over match-exc-underscores
159-
var field = _fields.Find(p => string.Equals(p.Name, columnName, StringComparison.Ordinal))
160-
?? _fields.Find(p => string.Equals(p.Name, backingFieldName, StringComparison.Ordinal))
161-
?? _fields.Find(p => string.Equals(p.Name, columnName, StringComparison.OrdinalIgnoreCase))
162-
?? _fields.Find(p => string.Equals(p.Name, backingFieldName, StringComparison.OrdinalIgnoreCase));
159+
var field = Array.Find(_fields, p => string.Equals(p.Name, columnName, StringComparison.Ordinal))
160+
?? Array.Find(_fields, p => string.Equals(p.Name, backingFieldName, StringComparison.Ordinal))
161+
?? Array.Find(_fields, p => string.Equals(p.Name, columnName, StringComparison.OrdinalIgnoreCase))
162+
?? Array.Find(_fields, p => string.Equals(p.Name, backingFieldName, StringComparison.OrdinalIgnoreCase));
163163

164164
if (field is null && MatchNamesWithUnderscores)
165165
{
166166
var effectiveColumnName = columnName.Replace("_", "");
167167
backingFieldName = "<" + effectiveColumnName + ">k__BackingField";
168168

169-
field = _fields.Find(p => string.Equals(p.Name, effectiveColumnName, StringComparison.Ordinal))
170-
?? _fields.Find(p => string.Equals(p.Name, backingFieldName, StringComparison.Ordinal))
171-
?? _fields.Find(p => string.Equals(p.Name, effectiveColumnName, StringComparison.OrdinalIgnoreCase))
172-
?? _fields.Find(p => string.Equals(p.Name, backingFieldName, StringComparison.OrdinalIgnoreCase));
169+
field = Array.Find(_fields, p => string.Equals(p.Name, effectiveColumnName, StringComparison.Ordinal))
170+
?? Array.Find(_fields, p => string.Equals(p.Name, backingFieldName, StringComparison.Ordinal))
171+
?? Array.Find(_fields, p => string.Equals(p.Name, effectiveColumnName, StringComparison.OrdinalIgnoreCase))
172+
?? Array.Find(_fields, p => string.Equals(p.Name, backingFieldName, StringComparison.OrdinalIgnoreCase));
173173
}
174174

175175
if (field is not null)

Dapper/DynamicParameters.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ public void AddDynamicParams(object? param)
6262
if (subDynamic.templates is not null)
6363
{
6464
templates ??= new List<object>();
65-
foreach (var t in subDynamic.templates)
66-
{
67-
templates.Add(t);
68-
}
65+
templates.AddRange(subDynamic.templates);
6966
}
7067
}
7168
else
@@ -212,14 +209,7 @@ protected void AddParameters(IDbCommand command, SqlMapper.Identity identity)
212209
}
213210

214211
// Now that the parameters are added to the command, let's place our output callbacks
215-
var tmp = outputCallbacks;
216-
if (tmp is not null)
217-
{
218-
foreach (var generator in tmp)
219-
{
220-
generator();
221-
}
222-
}
212+
outputCallbacks?.ForEach(generator => generator());
223213
}
224214

225215
foreach (var param in parameters.Values)

Dapper/FeatureSupport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Dapper
66
/// <summary>
77
/// Handles variances in features per DBMS
88
/// </summary>
9-
internal class FeatureSupport
9+
internal sealed class FeatureSupport
1010
{
1111
private static readonly FeatureSupport
1212
Default = new FeatureSupport(false),

Dapper/PublicAPI.Unshipped.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
#nullable enable
1+
#nullable enable
2+
static Dapper.SqlMapper.Settings.PreferTypeHandlersForEnums.get -> bool
3+
static Dapper.SqlMapper.Settings.PreferTypeHandlersForEnums.set -> void

0 commit comments

Comments
 (0)