Skip to content

Commit 1481c4d

Browse files
authored
Tooling and project updates (#1333)
This is a branch cleaning up old `#if` clauses, `.csproj` bits, Linux build compatibility, and a few other tid-bits (broken out by commit). In general: we're on 3.0 tooling and all previous cruft has been removed.
1 parent 7cac382 commit 1481c4d

38 files changed

+243
-338
lines changed

Dapper.Contrib/Dapper.Contrib.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<AssemblyName>Dapper.Contrib</AssemblyName>
4-
<PackageTags>orm;sql;micro-orm;dapper</PackageTags>
54
<Title>Dapper.Contrib</Title>
5+
<PackageTags>orm;sql;micro-orm;dapper</PackageTags>
66
<Description>The official collection of get, insert, update and delete helpers for Dapper.net. Also handles lists of entities and optional "dirty" tracking of interface-based entities.</Description>
77
<Authors>Sam Saffron;Johan Danforth</Authors>
88
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
99
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
1010
</PropertyGroup>
11-
<ItemGroup>
12-
<Compile Include="..\Dapper\TypeExtensions.cs" />
13-
</ItemGroup>
1411
<ItemGroup>
1512
<ProjectReference Include="..\Dapper\Dapper.csproj" />
1613
</ItemGroup>

Dapper.Contrib/SqlMapperExtensions.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@
66
using System.Text;
77
using System.Collections.Concurrent;
88
using System.Reflection.Emit;
9+
using System.Threading;
910

1011
using Dapper;
1112

12-
#if NETSTANDARD1_3
13-
using DataException = System.InvalidOperationException;
14-
#else
15-
using System.Threading;
16-
#endif
17-
1813
namespace Dapper.Contrib.Extensions
1914
{
2015
/// <summary>
@@ -290,15 +285,10 @@ private static string GetTableName(Type type)
290285
}
291286
else
292287
{
293-
#if NETSTANDARD1_3
294-
var info = type.GetTypeInfo();
295-
#else
296-
var info = type;
297-
#endif
298288
//NOTE: This as dynamic trick falls back to handle both our own Table-attribute as well as the one in EntityFramework
299289
var tableAttrName =
300-
info.GetCustomAttribute<TableAttribute>(false)?.Name
301-
?? (info.GetCustomAttributes(false).FirstOrDefault(attr => attr.GetType().Name == "TableAttribute") as dynamic)?.Name;
290+
type.GetCustomAttribute<TableAttribute>(false)?.Name
291+
?? (type.GetCustomAttributes(false).FirstOrDefault(attr => attr.GetType().Name == "TableAttribute") as dynamic)?.Name;
302292

303293
if (tableAttrName != null)
304294
{
@@ -562,7 +552,7 @@ private static class ProxyGenerator
562552

563553
private static AssemblyBuilder GetAsmBuilder(string name)
564554
{
565-
#if NETSTANDARD1_3 || NETSTANDARD2_0
555+
#if NETSTANDARD2_0
566556
return AssemblyBuilder.DefineDynamicAssembly(new AssemblyName { Name = name }, AssemblyBuilderAccess.Run);
567557
#else
568558
return Thread.GetDomain().DefineDynamicAssembly(new AssemblyName { Name = name }, AssemblyBuilderAccess.Run);
@@ -597,7 +587,7 @@ public static T GetInterfaceProxy<T>()
597587
CreateProperty<T>(typeBuilder, property.Name, property.PropertyType, setIsDirtyMethod, isId);
598588
}
599589

600-
#if NETSTANDARD1_3 || NETSTANDARD2_0
590+
#if NETSTANDARD2_0
601591
var generatedType = typeBuilder.CreateTypeInfo().AsType();
602592
#else
603593
var generatedType = typeBuilder.CreateType();
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
63
<AssemblyName>Dapper.ProviderTools</AssemblyName>
74
<PackageTags>orm;sql;micro-orm</PackageTags>
85
<Title>Dapper Provider Tools</Title>
@@ -13,8 +10,10 @@
1310
<Nullable>enable</Nullable>
1411
<LangVersion>8.0</LangVersion>
1512
</PropertyGroup>
16-
<ItemGroup>
13+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
1714
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
1815
</ItemGroup>
19-
16+
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
17+
<Reference Include="Microsoft.CSharp" />
18+
</ItemGroup>
2019
</Project>

Dapper.Rainbow/Dapper.Rainbow.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@
1010
<!-- TODO: Docs -->
1111
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
1212
</PropertyGroup>
13-
<ItemGroup>
14-
<Compile Include="..\Dapper\TypeExtensions.cs" />
15-
</ItemGroup>
1613
<ItemGroup>
1714
<ProjectReference Include="..\Dapper\Dapper.csproj" />
1815
</ItemGroup>
19-
2016
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
2117
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
2218
</ItemGroup>

Dapper.SqlBuilder/Dapper.SqlBuilder.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<ItemGroup>
1313
<ProjectReference Include="..\Dapper\Dapper.csproj" />
1414
</ItemGroup>
15-
1615
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
1716
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
1817
</ItemGroup>

Dapper.Tests.Contrib/Dapper.Tests.Contrib.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<AssemblyName>Dapper.Tests.Contrib</AssemblyName>
4-
<Title>Dapper.Tests.Contrib</Title>
54
<Description>Dapper Contrib Test Suite</Description>
6-
<DebugType>portable</DebugType>
7-
<OutputType>Exe</OutputType>
85
<GenerateDocumentationFile>false</GenerateDocumentationFile>
96
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
7+
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
108
</PropertyGroup>
119
<ItemGroup>
1210
<Compile Include="..\Dapper.Tests\Helpers\XunitSkippable.cs;..\Dapper\TypeExtensions.cs" />
@@ -19,12 +17,12 @@
1917
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.6" />
2018
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
2119
<PackageReference Include="MySqlConnector" Version="0.56.0" />
20+
<PackageReference Include="System.Data.SqlClient" Version="4.6.1" />
2221
<PackageReference Include="xunit" Version="$(xUnitVersion)" />
2322
<PackageReference Include="xunit.runner.visualstudio" Version="$(xUnitVersion)">
2423
<PrivateAssets>all</PrivateAssets>
2524
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2625
</PackageReference>
27-
<PackageReference Include="System.Data.SqlClient" Version="4.6.1" />
2826
</ItemGroup>
2927
<!-- note: define SQLCE if SQL CE is available -->
3028
</Project>

Dapper.Tests.Performance/Benchmarks.Dashing.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.ComponentModel;
1+
#if NET4X
2+
using System.ComponentModel;
23
using BenchmarkDotNet.Attributes;
34
using Dapper.Tests.Performance.Dashing;
45
using Dashing;
@@ -19,11 +20,15 @@ public void Setup()
1920
Session = database.BeginTransactionLessSession(_connection);
2021
}
2122

22-
[Benchmark(Description = "Get")]
23+
// This needs love to be compatible with current SDKs (weaving doesn't work and shouldn't be used here anyway (competition).
24+
// I'll file an issue with Dashing to see if someone can help me out here since I can't figure out from the docs how to
25+
// make it work correctly.
26+
//[Benchmark(Description = "Get")]
2327
public Dashing.Post Get()
2428
{
2529
Step();
2630
return Session.Get<Dashing.Post>(i);
2731
}
2832
}
2933
}
34+
#endif

Dapper.Tests.Performance/Benchmarks.EntityFramework.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using BenchmarkDotNet.Attributes;
1+
#if NET4X
2+
using BenchmarkDotNet.Attributes;
23
using System.ComponentModel;
34
using System.Linq;
45

@@ -38,3 +39,4 @@ public Post NoTracking()
3839
}
3940
}
4041
}
42+
#endif

Dapper.Tests.Performance/Benchmarks.HandCoded.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ public class HandCodedBenchmarks : BenchmarkBase
1111
{
1212
private SqlCommand _postCommand;
1313
private SqlParameter _idParam;
14-
#if !NETCOREAPP1_0
1514
private DataTable _table;
16-
#endif
1715

1816
[GlobalSetup]
1917
public void Setup()
2018
{
2119
BaseSetup();
22-
_postCommand = new SqlCommand("select * from Posts where Id = @Id", _connection);
20+
_postCommand = new SqlCommand("select Top 1 * from Posts where Id = @Id", _connection);
2321
_idParam = _postCommand.Parameters.Add("@Id", SqlDbType.Int);
2422
_postCommand.Prepare();
25-
#if !NETCOREAPP1_0
2623
_table = new DataTable
2724
{
2825
Columns =
@@ -42,7 +39,6 @@ public void Setup()
4239
{"Counter9", typeof (int)},
4340
}
4441
};
45-
#endif
4642
}
4743

4844
[Benchmark(Description = "SqlCommand")]

Dapper.Tests.Performance/Benchmarks.Linq2Sql.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using BenchmarkDotNet.Attributes;
1+
#if NET4X
2+
using BenchmarkDotNet.Attributes;
23
using Dapper.Tests.Performance.Linq2Sql;
34
using System;
45
using System.ComponentModel;
@@ -44,3 +45,4 @@ public Post ExecuteQuery()
4445
}
4546
}
4647
}
48+
#endif

0 commit comments

Comments
 (0)