Skip to content

Commit

Permalink
Tooling and project updates (DapperLib#1333)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
NickCraver authored Sep 26, 2019
1 parent 7cac382 commit 1481c4d
Show file tree
Hide file tree
Showing 38 changed files with 243 additions and 338 deletions.
5 changes: 1 addition & 4 deletions Dapper.Contrib/Dapper.Contrib.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Dapper.Contrib</AssemblyName>
<PackageTags>orm;sql;micro-orm;dapper</PackageTags>
<Title>Dapper.Contrib</Title>
<PackageTags>orm;sql;micro-orm;dapper</PackageTags>
<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>
<Authors>Sam Saffron;Johan Danforth</Authors>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Dapper\TypeExtensions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dapper\Dapper.csproj" />
</ItemGroup>
Expand Down
20 changes: 5 additions & 15 deletions Dapper.Contrib/SqlMapperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@
using System.Text;
using System.Collections.Concurrent;
using System.Reflection.Emit;
using System.Threading;

using Dapper;

#if NETSTANDARD1_3
using DataException = System.InvalidOperationException;
#else
using System.Threading;
#endif

namespace Dapper.Contrib.Extensions
{
/// <summary>
Expand Down Expand Up @@ -290,15 +285,10 @@ private static string GetTableName(Type type)
}
else
{
#if NETSTANDARD1_3
var info = type.GetTypeInfo();
#else
var info = type;
#endif
//NOTE: This as dynamic trick falls back to handle both our own Table-attribute as well as the one in EntityFramework
var tableAttrName =
info.GetCustomAttribute<TableAttribute>(false)?.Name
?? (info.GetCustomAttributes(false).FirstOrDefault(attr => attr.GetType().Name == "TableAttribute") as dynamic)?.Name;
type.GetCustomAttribute<TableAttribute>(false)?.Name
?? (type.GetCustomAttributes(false).FirstOrDefault(attr => attr.GetType().Name == "TableAttribute") as dynamic)?.Name;

if (tableAttrName != null)
{
Expand Down Expand Up @@ -562,7 +552,7 @@ private static class ProxyGenerator

private static AssemblyBuilder GetAsmBuilder(string name)
{
#if NETSTANDARD1_3 || NETSTANDARD2_0
#if NETSTANDARD2_0
return AssemblyBuilder.DefineDynamicAssembly(new AssemblyName { Name = name }, AssemblyBuilderAccess.Run);
#else
return Thread.GetDomain().DefineDynamicAssembly(new AssemblyName { Name = name }, AssemblyBuilderAccess.Run);
Expand Down Expand Up @@ -597,7 +587,7 @@ public static T GetInterfaceProxy<T>()
CreateProperty<T>(typeBuilder, property.Name, property.PropertyType, setIsDirtyMethod, isId);
}

#if NETSTANDARD1_3 || NETSTANDARD2_0
#if NETSTANDARD2_0
var generatedType = typeBuilder.CreateTypeInfo().AsType();
#else
var generatedType = typeBuilder.CreateType();
Expand Down
9 changes: 4 additions & 5 deletions Dapper.ProviderTools/Dapper.ProviderTools.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>

<AssemblyName>Dapper.ProviderTools</AssemblyName>
<PackageTags>orm;sql;micro-orm</PackageTags>
<Title>Dapper Provider Tools</Title>
Expand All @@ -13,8 +10,10 @@
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>
4 changes: 0 additions & 4 deletions Dapper.Rainbow/Dapper.Rainbow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@
<!-- TODO: Docs -->
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Dapper\TypeExtensions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dapper\Dapper.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
</ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion Dapper.SqlBuilder/Dapper.SqlBuilder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<ItemGroup>
<ProjectReference Include="..\Dapper\Dapper.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
</ItemGroup>
Expand Down
6 changes: 2 additions & 4 deletions Dapper.Tests.Contrib/Dapper.Tests.Contrib.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Dapper.Tests.Contrib</AssemblyName>
<Title>Dapper.Tests.Contrib</Title>
<Description>Dapper Contrib Test Suite</Description>
<DebugType>portable</DebugType>
<OutputType>Exe</OutputType>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Dapper.Tests\Helpers\XunitSkippable.cs;..\Dapper\TypeExtensions.cs" />
Expand All @@ -19,12 +17,12 @@
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MySqlConnector" Version="0.56.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.6.1" />
<PackageReference Include="xunit" Version="$(xUnitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(xUnitVersion)">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Data.SqlClient" Version="4.6.1" />
</ItemGroup>
<!-- note: define SQLCE if SQL CE is available -->
</Project>
9 changes: 7 additions & 2 deletions Dapper.Tests.Performance/Benchmarks.Dashing.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
#if NET4X
using System.ComponentModel;
using BenchmarkDotNet.Attributes;
using Dapper.Tests.Performance.Dashing;
using Dashing;
Expand All @@ -19,11 +20,15 @@ public void Setup()
Session = database.BeginTransactionLessSession(_connection);
}

[Benchmark(Description = "Get")]
// This needs love to be compatible with current SDKs (weaving doesn't work and shouldn't be used here anyway (competition).
// 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
// make it work correctly.
//[Benchmark(Description = "Get")]
public Dashing.Post Get()
{
Step();
return Session.Get<Dashing.Post>(i);
}
}
}
#endif
4 changes: 3 additions & 1 deletion Dapper.Tests.Performance/Benchmarks.EntityFramework.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BenchmarkDotNet.Attributes;
#if NET4X
using BenchmarkDotNet.Attributes;
using System.ComponentModel;
using System.Linq;

Expand Down Expand Up @@ -38,3 +39,4 @@ public Post NoTracking()
}
}
}
#endif
6 changes: 1 addition & 5 deletions Dapper.Tests.Performance/Benchmarks.HandCoded.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ public class HandCodedBenchmarks : BenchmarkBase
{
private SqlCommand _postCommand;
private SqlParameter _idParam;
#if !NETCOREAPP1_0
private DataTable _table;
#endif

[GlobalSetup]
public void Setup()
{
BaseSetup();
_postCommand = new SqlCommand("select * from Posts where Id = @Id", _connection);
_postCommand = new SqlCommand("select Top 1 * from Posts where Id = @Id", _connection);
_idParam = _postCommand.Parameters.Add("@Id", SqlDbType.Int);
_postCommand.Prepare();
#if !NETCOREAPP1_0
_table = new DataTable
{
Columns =
Expand All @@ -42,7 +39,6 @@ public void Setup()
{"Counter9", typeof (int)},
}
};
#endif
}

[Benchmark(Description = "SqlCommand")]
Expand Down
4 changes: 3 additions & 1 deletion Dapper.Tests.Performance/Benchmarks.Linq2Sql.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BenchmarkDotNet.Attributes;
#if NET4X
using BenchmarkDotNet.Attributes;
using Dapper.Tests.Performance.Linq2Sql;
using System;
using System.ComponentModel;
Expand Down Expand Up @@ -44,3 +45,4 @@ public Post ExecuteQuery()
}
}
}
#endif
4 changes: 3 additions & 1 deletion Dapper.Tests.Performance/Benchmarks.Susanoo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BenchmarkDotNet.Attributes;
#if NET4X
using BenchmarkDotNet.Attributes;
using Susanoo;
using Susanoo.Processing;
using System.ComponentModel;
Expand Down Expand Up @@ -64,3 +65,4 @@ public dynamic MappingStaticDynamic()
}
}
}
#endif
6 changes: 3 additions & 3 deletions Dapper.Tests.Performance/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ public Config()
Add(TargetMethodColumn.Method);
Add(new ReturnColum());
Add(StatisticColumn.Mean);
//Add(StatisticColumn.StdDev);
//Add(StatisticColumn.Error);
Add(StatisticColumn.StdDev);
Add(StatisticColumn.Error);
Add(BaselineRatioColumn.RatioMean);
Add(DefaultColumnProviders.Metrics);

Add(Job.ShortRun
.WithLaunchCount(1)
.WithWarmupCount(2)
.WithUnrollFactor(Iterations)
.WithIterationCount(1)
.WithIterationCount(10)
);
Orderer = new DefaultOrderer(SummaryOrderPolicy.FastestToSlowest);
Options |= ConfigOptions.JoinSummary;
Expand Down
103 changes: 48 additions & 55 deletions Dapper.Tests.Performance/Dapper.Tests.Performance.csproj
Original file line number Diff line number Diff line change
@@ -1,55 +1,48 @@
<Project>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
<PropertyGroup>
<AssemblyName>Dapper.Tests.Performance</AssemblyName>
<Title>Dapper.Tests.Performance</Title>
<Description>Dapper Core Performance Suite</Description>
<OutputType>Exe</OutputType>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TargetFrameworks>net462</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Dapper\Dapper.csproj" />
<ProjectReference Include="..\Dapper.Contrib\Dapper.Contrib.csproj" />
<ProjectReference Include="..\Dapper.EntityFramework\Dapper.EntityFramework.csproj" />
<PackageReference Include="Dashing" Version="2.2.0" />
<PackageReference Include="Dashing.Weaver" Version="2.2.0" />
<PackageReference Include="Belgrade.Sql.Client" Version="1.1.4" />
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" />
<PackageReference Include="DevExpress.Xpo" Version="19.1.5" />
<!--<PackageReference Include="BLToolkit" Version="4.3.6" />-->
<PackageReference Include="EntityFramework" Version="6.2.0" />
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="7.0.0" />
<PackageReference Include="linq2db.SqlServer" Version="2.9.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.6" />
<PackageReference Include="Microsoft.SqlServer.Types" Version="14.0.1016.290" />
<PackageReference Include="MySqlConnector" Version="0.56.0" />
<PackageReference Include="NHibernate" Version="5.2.5" />
<PackageReference Include="Iesi.Collections" Version="4.0.4" />
<PackageReference Include="Npgsql" Version="4.0.9" />
<PackageReference Include="PetaPoco" Version="5.1.306" />
<PackageReference Include="ServiceStack.OrmLite.SqlServer.Signed" Version="4.5.14" />
<PackageReference Include="Soma" Version="1.9.0.1" />
<PackageReference Include="SubSonic" Version="3.0.0.4" />
<PackageReference Include="Susanoo.SqlServer" Version="1.2.4.2" />
<PackageReference Include="System.Data.SQLite" Version="1.0.111" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Data.Linq" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<None Update="NHibernate\*.xml" CopyToOutputDirectory="Always" />
<Compile Update="Benchmarks.*.cs" DependentUpon="Benchmarks.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="SourceLink.Create.GitHub" Version="2.8.3" />
</ItemGroup>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
<PropertyGroup>
<WeaveArguments>-p "$(MSBuildThisFileDirectory)$(OutputPath)$(AssemblyName).exe" -t "Dapper.Tests.Performance.Dashing.DashingConfiguration"</WeaveArguments>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Dapper.Tests.Performance</AssemblyName>
<Title>Dapper.Tests.Performance</Title>
<Description>Dapper Core Performance Suite</Description>
<OutputType>Exe</OutputType>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Dapper\Dapper.csproj" />
<ProjectReference Include="..\Dapper.Contrib\Dapper.Contrib.csproj" />
<PackageReference Include="Dashing" Version="2.2.0" />
<PackageReference Include="Belgrade.Sql.Client" Version="1.1.4" />
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" />
<PackageReference Include="DevExpress.Xpo" Version="19.1.5" />
<!--<PackageReference Include="BLToolkit" Version="4.3.6" />-->
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="7.0.0" />
<PackageReference Include="linq2db.SqlServer" Version="2.9.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.6" />
<PackageReference Include="MySqlConnector" Version="0.56.0" />
<PackageReference Include="NHibernate" Version="5.2.5" />
<PackageReference Include="Iesi.Collections" Version="4.0.4" />
<PackageReference Include="Npgsql" Version="4.0.9" />
<PackageReference Include="PetaPoco" Version="5.1.306" />
<PackageReference Include="ServiceStack.OrmLite.SqlServer" Version="5.6.0" />
<PackageReference Include="System.Data.SQLite" Version="1.0.111" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="NHibernate\*.xml" />
<Compile Update="Benchmarks.*.cs" DependentUpon="Benchmarks.cs" />
</ItemGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net462'">
<DefineConstants>$(DefineConstants);NET4X</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<ProjectReference Include="..\Dapper.EntityFramework\Dapper.EntityFramework.csproj" />
<PackageReference Include="EntityFramework" Version="6.2.0" />
<PackageReference Include="Microsoft.SqlServer.Types" Version="14.0.1016.290" />
<PackageReference Include="Soma" Version="1.9.0.1" />
<PackageReference Include="SubSonic" Version="3.0.0.4" />
<PackageReference Include="Susanoo.SqlServer" Version="1.2.4.2" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data.Linq" />
</ItemGroup>
</Project>
4 changes: 3 additions & 1 deletion Dapper.Tests.Performance/EntityFramework/EFContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Data.Common;
#if NET4X
using System.Data.Common;
using System.Data.Entity;

namespace Dapper.Tests.Performance.EntityFramework
Expand All @@ -12,3 +13,4 @@ public EFContext(DbConnection connection, bool owned = false) : base(connection,
public DbSet<Post> Posts { get; set; }
}
}
#endif
Loading

0 comments on commit 1481c4d

Please sign in to comment.