Commit 7e5bd308 authored by Nick Craver's avatar Nick Craver

netstandard2.0 functionality (w/ runtime breaks)

This adds a netstandard2.0 build to Dapper (and StrongName until v2),
adds a netstandard2.0 test lineup, restores most functionality (except
UDTs for SQL, e.g. .UdtTypeName isn't in netstandard2), and also breaks
things not actually implemented or implemented correctly in
netstandard2.0. Pushing this up so we can work through these with the
.NET teams.

Several things are still broken here (and fail tests):
- Parameter decimal values (not filed yet)
- DataTables as parameters
(https://github.com/dotnet/corefx/issues/19708)
- .GetSchemaTable() (not yet filed, implementation is completely missing
from SqlDataReader in CoreFX)

While the compile is clean, the above are runtime issues.
`SqlParameter.UdtTypeName` is a separate issue, that one just wasn't in
`netstandard2.0` at all...so we can't support UDTs there until it is.
See https://github.com/dotnet/corefx/issues/17126 for details.
parent d72ae17a
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
using Dapper; using Dapper;
#if COREFX #if NETSTANDARD1_3
using DataException = System.InvalidOperationException; using DataException = System.InvalidOperationException;
#else #else
using System.Threading; using System.Threading;
...@@ -274,7 +274,7 @@ private static string GetTableName(Type type) ...@@ -274,7 +274,7 @@ private static string GetTableName(Type type)
{ {
//NOTE: This as dynamic trick should be able to handle both our own Table-attribute as well as the one in EntityFramework //NOTE: This as dynamic trick should be able to handle both our own Table-attribute as well as the one in EntityFramework
var tableAttr = type var tableAttr = type
#if COREFX #if NETSTANDARD1_3
.GetTypeInfo() .GetTypeInfo()
#endif #endif
.GetCustomAttributes(false).SingleOrDefault(attr => attr.GetType().Name == "TableAttribute") as dynamic; .GetCustomAttributes(false).SingleOrDefault(attr => attr.GetType().Name == "TableAttribute") as dynamic;
...@@ -516,7 +516,7 @@ private static class ProxyGenerator ...@@ -516,7 +516,7 @@ private static class ProxyGenerator
private static AssemblyBuilder GetAsmBuilder(string name) private static AssemblyBuilder GetAsmBuilder(string name)
{ {
#if COREFX #if NETSTANDARD1_3
return AssemblyBuilder.DefineDynamicAssembly(new AssemblyName { Name = name }, AssemblyBuilderAccess.Run); return AssemblyBuilder.DefineDynamicAssembly(new AssemblyName { Name = name }, AssemblyBuilderAccess.Run);
#else #else
return Thread.GetDomain().DefineDynamicAssembly(new AssemblyName { Name = name }, AssemblyBuilderAccess.Run); return Thread.GetDomain().DefineDynamicAssembly(new AssemblyName { Name = name }, AssemblyBuilderAccess.Run);
...@@ -551,7 +551,7 @@ public static T GetInterfaceProxy<T>() ...@@ -551,7 +551,7 @@ public static T GetInterfaceProxy<T>()
CreateProperty<T>(typeBuilder, property.Name, property.PropertyType, setIsDirtyMethod, isId); CreateProperty<T>(typeBuilder, property.Name, property.PropertyType, setIsDirtyMethod, isId);
} }
#if COREFX #if NETSTANDARD1_3
var generatedType = typeBuilder.CreateTypeInfo().AsType(); var generatedType = typeBuilder.CreateTypeInfo().AsType();
#else #else
var generatedType = typeBuilder.CreateType(); var generatedType = typeBuilder.CreateType();
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<Title>Dapper (Strong Named)</Title> <Title>Dapper (Strong Named)</Title>
<Description>A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite, SqlCE, Firebird etc..</Description> <Description>A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite, SqlCE, Firebird etc..</Description>
<Authors>Sam Saffron;Marc Gravell;Nick Craver</Authors> <Authors>Sam Saffron;Marc Gravell;Nick Craver</Authors>
<TargetFrameworks>net40;net45;net451;netstandard1.3</TargetFrameworks> <TargetFrameworks>net40;net45;net451;netstandard1.3;netstandard2.0</TargetFrameworks>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign> <PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
</PropertyGroup> </PropertyGroup>
...@@ -30,4 +30,9 @@ ...@@ -30,4 +30,9 @@
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" /> <PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
<PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" /> <PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Data.SqlClient" Version="4.4.0-preview1-25305-02" />
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" />
</ItemGroup>
</Project> </Project>
...@@ -6,10 +6,7 @@ ...@@ -6,10 +6,7 @@
<DebugType>portable</DebugType> <DebugType>portable</DebugType>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<GenerateDocumentationFile>false</GenerateDocumentationFile> <GenerateDocumentationFile>false</GenerateDocumentationFile>
<TargetFramework>netcoreapp1.0</TargetFramework> <TargetFrameworks>netcoreapp1.0;netcoreapp2.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<DefineConstants>$(DefineConstants);COREFX;</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\Dapper.Tests\Helpers\Assert.cs;..\Dapper.Tests\Helpers\XunitSkippable.cs;..\Dapper\TypeExtensions.cs" /> <Compile Include="..\Dapper.Tests\Helpers\Assert.cs;..\Dapper.Tests\Helpers\XunitSkippable.cs;..\Dapper\TypeExtensions.cs" />
...@@ -19,15 +16,14 @@ ...@@ -19,15 +16,14 @@
<ProjectReference Include="..\Dapper\Dapper.csproj" /> <ProjectReference Include="..\Dapper\Dapper.csproj" />
<ProjectReference Include="..\Dapper.Contrib\Dapper.Contrib.csproj" /> <ProjectReference Include="..\Dapper.Contrib\Dapper.Contrib.csproj" />
<ProjectReference Include="..\Dapper.SqlBuilder\Dapper.SqlBuilder.csproj" /> <ProjectReference Include="..\Dapper.SqlBuilder\Dapper.SqlBuilder.csproj" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="1.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.3.0" /> <PackageReference Include="MySql.Data" Version="7.0.7-m61" />
<PackageReference Include="System.Data.SqlClient" Version="4.4.0-preview1-25305-02" />
<PackageReference Include="xunit" Version="2.3.0-beta1-build3642" /> <PackageReference Include="xunit" Version="2.3.0-beta1-build3642" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta1-build1309" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta1-build1309" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta1-build3642" /> <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta1-build3642" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<PackageReference Include="Microsoft.Data.Sqlite" Version="1.1.0" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
......
...@@ -5,10 +5,12 @@ ...@@ -5,10 +5,12 @@
using Dapper.Contrib.Extensions; using Dapper.Contrib.Extensions;
#if !COREFX #if !NETCOREAPP1_0
using System.Data.SqlServerCe;
using System.Transactions; using System.Transactions;
#endif #endif
#if !NETCOREAPP1_0 && !NETCOREAPP2_0
using System.Data.SqlServerCe;
#endif
using FactAttribute = Dapper.Tests.Contrib.SkippableFactAttribute; using FactAttribute = Dapper.Tests.Contrib.SkippableFactAttribute;
namespace Dapper.Tests.Contrib namespace Dapper.Tests.Contrib
...@@ -420,7 +422,7 @@ public void InsertGetUpdate() ...@@ -420,7 +422,7 @@ public void InsertGetUpdate()
} }
} }
#if !COREFX #if !NETCOREAPP1_0 && !NETCOREAPP2_0
[Fact(Skip = "Not parallel friendly - thinking about how to test this")] [Fact(Skip = "Not parallel friendly - thinking about how to test this")]
public void InsertWithCustomDbType() public void InsertWithCustomDbType()
{ {
...@@ -525,7 +527,7 @@ public void Transactions() ...@@ -525,7 +527,7 @@ public void Transactions()
} }
} }
#if !COREFX #if !NETCOREAPP1_0
[Fact] [Fact]
public void TransactionScope() public void TransactionScope()
{ {
...@@ -632,4 +634,3 @@ public void DeleteAll() ...@@ -632,4 +634,3 @@ public void DeleteAll()
} }
} }
} }
using System; using Microsoft.Data.Sqlite;
using MySql.Data.MySqlClient;
using System;
using System.Data; using System.Data;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.IO; using System.IO;
using Xunit; using Xunit;
using Xunit.Sdk; using Xunit.Sdk;
#if COREFX
using Microsoft.Data.Sqlite; #if !NETCOREAPP1_0 && !NETCOREAPP2_0
#else
using System.Data.SQLite;
using System.Data.SqlServerCe; using System.Data.SqlServerCe;
using MySql.Data.MySqlClient;
using SqliteConnection = System.Data.SQLite.SQLiteConnection;
#endif #endif
namespace Dapper.Tests.Contrib namespace Dapper.Tests.Contrib
...@@ -60,7 +58,6 @@ static SqlServerTestSuite() ...@@ -60,7 +58,6 @@ static SqlServerTestSuite()
} }
} }
#if !COREFX
public class MySqlServerTestSuite : TestSuite public class MySqlServerTestSuite : TestSuite
{ {
const string DbName = "DapperContribTests"; const string DbName = "DapperContribTests";
...@@ -115,14 +112,11 @@ static MySqlServerTestSuite() ...@@ -115,14 +112,11 @@ static MySqlServerTestSuite()
} }
} }
} }
// This doesn't work on COREFX right now due to:
// In Visual Studio: Interop loads (works from console, though)
// In general: parameter names, see https://github.com/StackExchange/dapper-dot-net/issues/375
public class SQLiteTestSuite : TestSuite public class SQLiteTestSuite : TestSuite
{ {
const string FileName = "Test.DB.sqlite"; const string FileName = "Test.DB.sqlite";
public static string ConnectionString => $"Filename={FileName};"; public static string ConnectionString => $"Filename=./{FileName};Mode=ReadWriteCreate;";
public override IDbConnection GetConnection() => new SqliteConnection(ConnectionString); public override IDbConnection GetConnection() => new SqliteConnection(ConnectionString);
static SQLiteTestSuite() static SQLiteTestSuite()
...@@ -131,7 +125,6 @@ static SQLiteTestSuite() ...@@ -131,7 +125,6 @@ static SQLiteTestSuite()
{ {
File.Delete(FileName); File.Delete(FileName);
} }
SqliteConnection.CreateFile(FileName);
using (var connection = new SqliteConnection(ConnectionString)) using (var connection = new SqliteConnection(ConnectionString))
{ {
connection.Open(); connection.Open();
...@@ -147,6 +140,7 @@ static SQLiteTestSuite() ...@@ -147,6 +140,7 @@ static SQLiteTestSuite()
} }
} }
#if !NETCOREAPP1_0 && !NETCOREAPP2_0
public class SqlCETestSuite : TestSuite public class SqlCETestSuite : TestSuite
{ {
const string FileName = "Test.DB.sdf"; const string FileName = "Test.DB.sdf";
......
...@@ -9,7 +9,7 @@ public class HandCodedBenchmarks : BenchmarkBase ...@@ -9,7 +9,7 @@ public class HandCodedBenchmarks : BenchmarkBase
{ {
private SqlCommand _postCommand; private SqlCommand _postCommand;
private SqlParameter _idParam; private SqlParameter _idParam;
#if !COREFX #if !NETCOREAPP1_0
private DataTable _table; private DataTable _table;
#endif #endif
...@@ -24,7 +24,7 @@ public void Setup() ...@@ -24,7 +24,7 @@ public void Setup()
Counter1,Counter2,Counter3,Counter4,Counter5,Counter6,Counter7,Counter8,Counter9 from Posts where Id = @Id" Counter1,Counter2,Counter3,Counter4,Counter5,Counter6,Counter7,Counter8,Counter9 from Posts where Id = @Id"
}; };
_idParam = _postCommand.Parameters.Add("@Id", SqlDbType.Int); _idParam = _postCommand.Parameters.Add("@Id", SqlDbType.Int);
#if !COREFX #if !NETCOREAPP1_0
_table = new DataTable _table = new DataTable
{ {
Columns = Columns =
......
...@@ -332,7 +332,7 @@ public async Task RunAsync(int iterations) ...@@ -332,7 +332,7 @@ public async Task RunAsync(int iterations)
} }
}, "Hand Coded"); }, "Hand Coded");
#if !COREFX #if !NETSTANDARD1_3
var table = new DataTable var table = new DataTable
{ {
Columns = Columns =
......
#if !COREFX #if !NETSTANDARD1_3
#pragma warning disable 1591 #pragma warning disable 1591
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
......
#if !COREFX #if !NETSTANDARD1_3
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
......
#if !COREFX #if !NETSTANDARD1_3
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
......
...@@ -218,7 +218,7 @@ public async Task TestMultiClosedConnAsyncViaFirstOrDefault() ...@@ -218,7 +218,7 @@ public async Task TestMultiClosedConnAsyncViaFirstOrDefault()
} }
} }
#if !COREFX #if !NETCOREAPP1_0
[Fact] [Fact]
public async Task ExecuteReaderOpenAsync() public async Task ExecuteReaderOpenAsync()
{ {
...@@ -318,8 +318,8 @@ public async Task LiteralInAsync() ...@@ -318,8 +318,8 @@ public async Task LiteralInAsync()
new { ids = new[] { 1, 3, 4 } }).ConfigureAwait(false)).Single(); new { ids = new[] { 1, 3, 4 } }).ConfigureAwait(false)).Single();
count.IsEqualTo(2); count.IsEqualTo(2);
} }
[Fact] [FactLongRunning]
public async Task RunSequentialVersusParallelAsync() public async Task RunSequentialVersusParallelAsync()
{ {
var ids = Enumerable.Range(1, 20000).Select(id => new { id }).ToArray(); var ids = Enumerable.Range(1, 20000).Select(id => new { id }).ToArray();
...@@ -336,7 +336,7 @@ public async Task RunSequentialVersusParallelAsync() ...@@ -336,7 +336,7 @@ public async Task RunSequentialVersusParallelAsync()
Console.WriteLine("Pipeline: {0}ms", watch.ElapsedMilliseconds); Console.WriteLine("Pipeline: {0}ms", watch.ElapsedMilliseconds);
} }
[Fact] [FactLongRunning]
public void RunSequentialVersusParallelSync() public void RunSequentialVersusParallelSync()
{ {
var ids = Enumerable.Range(1, 20000).Select(id => new { id }).ToArray(); var ids = Enumerable.Range(1, 20000).Select(id => new { id }).ToArray();
......
...@@ -104,28 +104,6 @@ public bool GetWentThroughProperConstructor() ...@@ -104,28 +104,6 @@ public bool GetWentThroughProperConstructor()
} }
} }
#if LINQ2SQL
private class NoDefaultConstructorWithBinary
{
public System.Data.Linq.Binary Value { get; set; }
public int Ynt { get; set; }
public NoDefaultConstructorWithBinary(System.Data.Linq.Binary val)
{
Value = val;
}
}
[Fact]
public void TestNoDefaultConstructorBinary()
{
byte[] orig = new byte[20];
new Random(123456).NextBytes(orig);
var input = new System.Data.Linq.Binary(orig);
var output = connection.Query<NoDefaultConstructorWithBinary>("select @input as val", new { input }).First().Value;
output.ToArray().IsSequenceEqualTo(orig);
}
#endif
[Fact] [Fact]
public void Issue461_TypeHandlerWorksInConstructor() public void Issue461_TypeHandlerWorksInConstructor()
{ {
......
...@@ -6,14 +6,11 @@ ...@@ -6,14 +6,11 @@
<GenerateDocumentationFile>false</GenerateDocumentationFile> <GenerateDocumentationFile>false</GenerateDocumentationFile>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<TargetFrameworks>net452;netcoreapp1.0</TargetFrameworks> <TargetFrameworks>net452;netcoreapp1.0;netcoreapp2.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net452' "> <PropertyGroup Condition=" '$(TargetFramework)' == 'net452' ">
<DefineConstants>$(DefineConstants);NET45;MYSQL;ENTITY_FRAMEWORK;LINQ2SQL;FIREBIRD;SQL_CE;POSTGRESQL;OLEDB;SQLITE</DefineConstants> <DefineConstants>$(DefineConstants);ENTITY_FRAMEWORK;LINQ2SQL;SQL_CE;OLEDB</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<DefineConstants>$(DefineConstants);COREFX</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="Test.DB.sdf" /> <None Remove="Test.DB.sdf" />
...@@ -21,23 +18,22 @@ ...@@ -21,23 +18,22 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Dapper\Dapper.csproj" /> <ProjectReference Include="..\Dapper\Dapper.csproj" />
<ProjectReference Include="..\Dapper.Contrib\Dapper.Contrib.csproj" /> <ProjectReference Include="..\Dapper.Contrib\Dapper.Contrib.csproj" />
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="5.9.0.1" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="1.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.3.0" /> <PackageReference Include="MySql.Data" Version="7.0.7-m61" />
<PackageReference Include="Npgsql" Version="3.2.2" />
<PackageReference Include="System.Data.SqlClient" Version="4.4.0-preview1-25305-02" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" /> <PackageReference Include="System.ValueTuple" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.3.0-beta1-build3642" /> <PackageReference Include="xunit" Version="2.3.0-beta1-build3642" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta1-build1309" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta1-build1309" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta1-build3642" /> <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta1-build3642" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' "> <ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<ProjectReference Include="..\Dapper.EntityFramework\Dapper.EntityFramework.csproj" /> <ProjectReference Include="..\Dapper.EntityFramework\Dapper.EntityFramework.csproj" />
<PackageReference Include="EntityFramework" Version="6.1.3" />
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="5.8.0" />
<PackageReference Include="Microsoft.SqlServer.Compact" Version="4.0.8876.1" /> <PackageReference Include="Microsoft.SqlServer.Compact" Version="4.0.8876.1" />
<PackageReference Include="Microsoft.SqlServer.Types" Version="14.0.314.76" /> <PackageReference Include="Microsoft.SqlServer.Types" Version="14.0.314.76" />
<PackageReference Include="MySql.Data" Version="7.0.7-m61" />
<PackageReference Include="Npgsql" Version="3.2.2" />
<PackageReference Include="System.Data.SQLite" Version="1.0.104" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Data.Linq" /> <Reference Include="System.Data.Linq" />
...@@ -49,7 +45,6 @@ ...@@ -49,7 +45,6 @@
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' "> <ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<PackageReference Include="System.Ben" Version="1.0.0" /> <PackageReference Include="System.Ben" Version="1.0.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="1.1.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
using System; using System;
using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit; using Xunit;
namespace Dapper.Tests namespace Dapper.Tests
......
...@@ -4,20 +4,6 @@ ...@@ -4,20 +4,6 @@
namespace Dapper.Tests namespace Dapper.Tests
{ {
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class FactUnlessCoreCLRAttribute : FactAttribute
{
public FactUnlessCoreCLRAttribute(string url)
{
#if COREFX
Skip = $"CoreFX: {url}";
#endif
this.Url = url;
}
public string Url { get; }
}
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class FactLongRunningAttribute : FactAttribute public sealed class FactLongRunningAttribute : FactAttribute
{ {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
using System.Linq; using System.Linq;
using Xunit; using Xunit;
#if COREFX #if NETCOREAPP1_0
using System.Collections; using System.Collections;
using System.Dynamic; using System.Dynamic;
using System.Data.SqlTypes; using System.Data.SqlTypes;
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
#endif #endif
#if COREFX #if NETCOREAPP1_0
namespace System namespace System
{ {
public enum GenericUriParserOptions public enum GenericUriParserOptions
...@@ -507,7 +507,7 @@ public void TestInheritance() ...@@ -507,7 +507,7 @@ public void TestInheritance()
list.First().Base2.IsEqualTo("Four"); list.First().Base2.IsEqualTo("Four");
} }
#if !COREFX #if !NETCOREAPP1_0
[Fact] [Fact]
public void ExecuteReader() public void ExecuteReader()
{ {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
using Xunit; using Xunit;
using System.Globalization; using System.Globalization;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Diagnostics;
#if ENTITY_FRAMEWORK #if ENTITY_FRAMEWORK
using System.Data.Entity.Spatial; using System.Data.Entity.Spatial;
...@@ -217,7 +218,7 @@ public void TestMassiveStrings() ...@@ -217,7 +218,7 @@ public void TestMassiveStrings()
.IsEqualTo(str); .IsEqualTo(str);
} }
#if !COREFX #if !NETCOREAPP1_0
[Fact] [Fact]
public void TestTVPWithAnonymousObject() public void TestTVPWithAnonymousObject()
{ {
...@@ -491,7 +492,7 @@ public SO29596645_RuleTableValuedParameters(string parameterName) ...@@ -491,7 +492,7 @@ public SO29596645_RuleTableValuedParameters(string parameterName)
public void AddParameters(IDbCommand command, SqlMapper.Identity identity) public void AddParameters(IDbCommand command, SqlMapper.Identity identity)
{ {
Console.WriteLine("> AddParameters"); Debug.WriteLine("> AddParameters");
var lazy = (SqlCommand)command; var lazy = (SqlCommand)command;
lazy.Parameters.AddWithValue("Id", 7); lazy.Parameters.AddWithValue("Id", 7);
var table = new DataTable var table = new DataTable
...@@ -500,7 +501,7 @@ public void AddParameters(IDbCommand command, SqlMapper.Identity identity) ...@@ -500,7 +501,7 @@ public void AddParameters(IDbCommand command, SqlMapper.Identity identity)
Rows = { { 4 }, { 9 } } Rows = { { 4 }, { 9 } }
}; };
lazy.Parameters.AddWithValue("Rules", table); lazy.Parameters.AddWithValue("Rules", table);
Console.WriteLine("< AddParameters"); Debug.WriteLine("< AddParameters");
} }
} }
......
...@@ -103,7 +103,7 @@ public void SO24605346_ProcsAndStrings() ...@@ -103,7 +103,7 @@ public void SO24605346_ProcsAndStrings()
private class PracticeRebateOrders private class PracticeRebateOrders
{ {
public string fTaxInvoiceNumber; public string fTaxInvoiceNumber;
#if !COREFX #if !NETCOREAPP1_0
[System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
#endif #endif
public string TaxInvoiceNumber public string TaxInvoiceNumber
......
#if FIREBIRD using FirebirdSql.Data.FirebirdClient;
using FirebirdSql.Data.FirebirdClient;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using Xunit; using Xunit;
...@@ -45,5 +44,4 @@ public void Issue178_Firebird() ...@@ -45,5 +44,4 @@ public void Issue178_Firebird()
} }
} }
} }
} }
#endif \ No newline at end of file
\ No newline at end of file
...@@ -38,6 +38,27 @@ private class WithBinary ...@@ -38,6 +38,27 @@ private class WithBinary
{ {
public System.Data.Linq.Binary Value { get; set; } public System.Data.Linq.Binary Value { get; set; }
} }
private class NoDefaultConstructorWithBinary
{
public System.Data.Linq.Binary Value { get; set; }
public int Ynt { get; set; }
public NoDefaultConstructorWithBinary(System.Data.Linq.Binary val)
{
Value = val;
}
}
[Fact]
public void TestNoDefaultConstructorBinary()
{
byte[] orig = new byte[20];
new Random(123456).NextBytes(orig);
var input = new System.Data.Linq.Binary(orig);
var output = connection.Query<NoDefaultConstructorWithBinary>("select @input as val", new { input }).First().Value;
output.ToArray().IsSequenceEqualTo(orig);
}
} }
} }
#endif #endif
\ No newline at end of file
#if MYSQL using System;
using System;
using System.Linq; using System.Linq;
using Xunit; using Xunit;
...@@ -185,5 +184,4 @@ static FactMySqlAttribute() ...@@ -185,5 +184,4 @@ static FactMySqlAttribute()
} }
} }
} }
} }
#endif \ No newline at end of file
\ No newline at end of file
#if POSTGRESQL using System;
using System;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using Xunit; using Xunit;
...@@ -80,5 +79,4 @@ static FactPostgresqlAttribute() ...@@ -80,5 +79,4 @@ static FactPostgresqlAttribute()
} }
} }
} }
} }
#endif \ No newline at end of file
\ No newline at end of file
#if SQLITE using Microsoft.Data.Sqlite;
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Data.SQLite;
using System.Data;
using Xunit; using Xunit;
namespace Dapper.Tests namespace Dapper.Tests
{ {
public class SqliteTests : TestBase public class SqliteTests : TestBase
{ {
protected static SQLiteConnection GetSQLiteConnection(bool open = true) protected static SqliteConnection GetSQLiteConnection(bool open = true)
{ {
var connection = new SQLiteConnection("Data Source=:memory:"); var connection = new SqliteConnection("Data Source=:memory:");
if (open) connection.Open(); if (open) connection.Open();
return connection; return connection;
} }
...@@ -82,11 +80,7 @@ private void Isse467_SqliteParameterNaming(bool prefix) ...@@ -82,11 +80,7 @@ private void Isse467_SqliteParameterNaming(bool prefix)
{ {
var cmd = connection.CreateCommand(); var cmd = connection.CreateCommand();
cmd.CommandText = "select @foo"; cmd.CommandText = "select @foo";
#if NET45
const DbType type = DbType.Int32;
#else
const SqliteType type = SqliteType.Integer; const SqliteType type = SqliteType.Integer;
#endif
cmd.Parameters.Add(prefix ? "@foo" : "foo", type).Value = 42; cmd.Parameters.Add(prefix ? "@foo" : "foo", type).Value = 42;
var i = Convert.ToInt32(cmd.ExecuteScalar()); var i = Convert.ToInt32(cmd.ExecuteScalar());
i.IsEqualTo(42); i.IsEqualTo(42);
...@@ -118,5 +112,4 @@ static FactSqliteAttribute() ...@@ -118,5 +112,4 @@ static FactSqliteAttribute()
} }
} }
} }
} }
#endif \ No newline at end of file
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
using System.Data; using System.Data;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Globalization; using System.Globalization;
#if !COREFX #if !NETCOREAPP1_0
using System.Threading; using System.Threading;
#endif #endif
...@@ -45,7 +45,7 @@ public SqlConnection GetClosedConnection() ...@@ -45,7 +45,7 @@ public SqlConnection GetClosedConnection()
protected static CultureInfo ActiveCulture protected static CultureInfo ActiveCulture
{ {
#if COREFX #if NETCOREAPP1_0
get { return CultureInfo.CurrentCulture; } get { return CultureInfo.CurrentCulture; }
set { CultureInfo.CurrentCulture = value; } set { CultureInfo.CurrentCulture = value; }
#else #else
...@@ -58,8 +58,8 @@ static TestBase() ...@@ -58,8 +58,8 @@ static TestBase()
{ {
Console.WriteLine("Dapper: " + typeof(SqlMapper).AssemblyQualifiedName); Console.WriteLine("Dapper: " + typeof(SqlMapper).AssemblyQualifiedName);
Console.WriteLine("Using Connectionstring: {0}", ConnectionString); Console.WriteLine("Using Connectionstring: {0}", ConnectionString);
#if COREFX #if NETCOREAPP1_0
Console.WriteLine("CoreCLR"); Console.WriteLine("CoreCLR (netcoreapp1.0)");
#else #else
Console.WriteLine(".NET: " + Environment.Version); Console.WriteLine(".NET: " + Environment.Version);
Console.Write("Loading native assemblies for SQL types..."); Console.Write("Loading native assemblies for SQL types...");
......
...@@ -545,7 +545,7 @@ public void TestCustomTypeMap() ...@@ -545,7 +545,7 @@ public void TestCustomTypeMap()
private static string GetDescriptionFromAttribute(MemberInfo member) private static string GetDescriptionFromAttribute(MemberInfo member)
{ {
if (member == null) return null; if (member == null) return null;
#if COREFX #if NETCOREAPP1_0
var data = member.CustomAttributes.FirstOrDefault(x => x.AttributeType == typeof(DescriptionAttribute)); var data = member.CustomAttributes.FirstOrDefault(x => x.AttributeType == typeof(DescriptionAttribute));
return (string)data?.ConstructorArguments.Single().Value; return (string)data?.ConstructorArguments.Single().Value;
#else #else
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<Title>Dapper</Title> <Title>Dapper</Title>
<Description>A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite, SqlCE, Firebird etc..</Description> <Description>A high performance Micro-ORM supporting SQL Server, MySQL, Sqlite, SqlCE, Firebird etc..</Description>
<Authors>Sam Saffron;Marc Gravell;Nick Craver</Authors> <Authors>Sam Saffron;Marc Gravell;Nick Craver</Authors>
<TargetFrameworks>net40;net45;net451;netstandard1.3</TargetFrameworks> <TargetFrameworks>net40;net45;net451;netstandard1.3;netstandard2.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' OR '$(TargetFramework)' == 'net45' OR '$(TargetFramework)' == 'net451' "> <ItemGroup Condition=" '$(TargetFramework)' == 'net40' OR '$(TargetFramework)' == 'net45' OR '$(TargetFramework)' == 'net451' ">
<Reference Include="System" /> <Reference Include="System" />
...@@ -25,4 +25,9 @@ ...@@ -25,4 +25,9 @@
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" /> <PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
<PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" /> <PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Data.SqlClient" Version="4.4.0-preview1-25305-02" />
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" />
</ItemGroup>
</Project> </Project>
using System; using System;
using System.Data; using System.Data;
#if !COREFX #if !NETSTANDARD1_3
namespace Dapper namespace Dapper
{ {
internal sealed class DataTableHandler : SqlMapper.ITypeHandler internal sealed class DataTableHandler : SqlMapper.ITypeHandler
......
...@@ -26,7 +26,7 @@ public DefaultTypeMap(Type type) ...@@ -26,7 +26,7 @@ public DefaultTypeMap(Type type)
Properties = GetSettableProps(type); Properties = GetSettableProps(type);
_type = type; _type = type;
} }
#if COREFX #if NETSTANDARD1_3
private static bool IsParameterMatch(ParameterInfo[] x, ParameterInfo[] y) private static bool IsParameterMatch(ParameterInfo[] x, ParameterInfo[] y)
{ {
if (ReferenceEquals(x, y)) return true; if (ReferenceEquals(x, y)) return true;
...@@ -40,7 +40,7 @@ private static bool IsParameterMatch(ParameterInfo[] x, ParameterInfo[] y) ...@@ -40,7 +40,7 @@ private static bool IsParameterMatch(ParameterInfo[] x, ParameterInfo[] y)
internal static MethodInfo GetPropertySetter(PropertyInfo propertyInfo, Type type) internal static MethodInfo GetPropertySetter(PropertyInfo propertyInfo, Type type)
{ {
if (propertyInfo.DeclaringType == type) return propertyInfo.GetSetMethod(true); if (propertyInfo.DeclaringType == type) return propertyInfo.GetSetMethod(true);
#if COREFX #if NETSTANDARD1_3
return propertyInfo.DeclaringType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) return propertyInfo.DeclaringType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.Single(x => x.Name == propertyInfo.Name .Single(x => x.Name == propertyInfo.Name
&& x.PropertyType == propertyInfo.PropertyType && x.PropertyType == propertyInfo.PropertyType
...@@ -118,7 +118,7 @@ public ConstructorInfo FindConstructor(string[] names, Type[] types) ...@@ -118,7 +118,7 @@ public ConstructorInfo FindConstructor(string[] names, Type[] types)
public ConstructorInfo FindExplicitConstructor() public ConstructorInfo FindExplicitConstructor()
{ {
var constructors = _type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); var constructors = _type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
#if COREFX #if NETSTANDARD1_3
var withAttr = constructors.Where(c => c.CustomAttributes.Any(x => x.AttributeType == typeof(ExplicitConstructorAttribute))).ToList(); var withAttr = constructors.Where(c => c.CustomAttributes.Any(x => x.AttributeType == typeof(ExplicitConstructorAttribute))).ToList();
#else #else
var withAttr = constructors.Where(c => c.GetCustomAttributes(typeof(ExplicitConstructorAttribute), true).Length > 0).ToList(); var withAttr = constructors.Where(c => c.GetCustomAttributes(typeof(ExplicitConstructorAttribute), true).Length > 0).ToList();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
using System.Reflection; using System.Reflection;
using System.Reflection.Emit; using System.Reflection.Emit;
#if COREFX #if NETSTANDARD1_3
using ApplicationException = System.InvalidOperationException; using ApplicationException = System.InvalidOperationException;
#endif #endif
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
#if !COREFX #if !NETSTANDARD1_3
namespace Dapper namespace Dapper
{ {
internal sealed class SqlDataRecordHandler : SqlMapper.ITypeHandler internal sealed class SqlDataRecordHandler : SqlMapper.ITypeHandler
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Reflection; using System.Reflection;
#if !COREFX #if !NETSTANDARD1_3
namespace Dapper namespace Dapper
{ {
/// <summary> /// <summary>
......
...@@ -11,7 +11,7 @@ public static partial class SqlMapper ...@@ -11,7 +11,7 @@ public static partial class SqlMapper
/// </summary> /// </summary>
/// <typeparam name="T">The type to have a cache for.</typeparam> /// <typeparam name="T">The type to have a cache for.</typeparam>
[Obsolete(ObsoleteInternalUsageOnly, false)] [Obsolete(ObsoleteInternalUsageOnly, false)]
#if !COREFX #if !NETSTANDARD1_3
[Browsable(false)] [Browsable(false)]
#endif #endif
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
using System.Xml; using System.Xml;
using System.Xml.Linq; using System.Xml.Linq;
#if COREFX #if NETSTANDARD1_3
using DataException = System.InvalidOperationException; using DataException = System.InvalidOperationException;
#endif #endif
...@@ -217,7 +217,7 @@ static SqlMapper() ...@@ -217,7 +217,7 @@ static SqlMapper()
private static void ResetTypeHandlers(bool clone) private static void ResetTypeHandlers(bool clone)
{ {
typeHandlers = new Dictionary<Type, ITypeHandler>(); typeHandlers = new Dictionary<Type, ITypeHandler>();
#if !COREFX #if !NETSTANDARD1_3
AddTypeHandlerImpl(typeof(DataTable), new DataTableHandler(), clone); AddTypeHandlerImpl(typeof(DataTable), new DataTableHandler(), clone);
try try
{ {
...@@ -230,7 +230,7 @@ private static void ResetTypeHandlers(bool clone) ...@@ -230,7 +230,7 @@ private static void ResetTypeHandlers(bool clone)
AddTypeHandlerImpl(typeof(XElement), new XElementHandler(), clone); AddTypeHandlerImpl(typeof(XElement), new XElementHandler(), clone);
} }
#if !COREFX #if !NETSTANDARD1_3
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
private static void AddSqlDataRecordsTypeHandler(bool clone) private static void AddSqlDataRecordsTypeHandler(bool clone)
{ {
...@@ -348,7 +348,7 @@ public static void AddTypeHandlerImpl(Type type, ITypeHandler handler, bool clon ...@@ -348,7 +348,7 @@ public static void AddTypeHandlerImpl(Type type, ITypeHandler handler, bool clon
/// </summary> /// </summary>
/// <param name="value">The object to get a corresponding database type for.</param> /// <param name="value">The object to get a corresponding database type for.</param>
[Obsolete(ObsoleteInternalUsageOnly, false)] [Obsolete(ObsoleteInternalUsageOnly, false)]
#if !COREFX #if !NETSTANDARD1_3
[Browsable(false)] [Browsable(false)]
#endif #endif
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
...@@ -367,7 +367,7 @@ public static DbType GetDbType(object value) ...@@ -367,7 +367,7 @@ public static DbType GetDbType(object value)
/// <param name="demand">Whether to demand a value (throw if missing).</param> /// <param name="demand">Whether to demand a value (throw if missing).</param>
/// <param name="handler">The handler for <paramref name="type"/>.</param> /// <param name="handler">The handler for <paramref name="type"/>.</param>
[Obsolete(ObsoleteInternalUsageOnly, false)] [Obsolete(ObsoleteInternalUsageOnly, false)]
#if !COREFX #if !NETSTANDARD1_3
[Browsable(false)] [Browsable(false)]
#endif #endif
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
...@@ -397,7 +397,7 @@ public static DbType LookupDbType(Type type, string name, bool demand, out IType ...@@ -397,7 +397,7 @@ public static DbType LookupDbType(Type type, string name, bool demand, out IType
return DynamicParameters.EnumerableMultiParameter; return DynamicParameters.EnumerableMultiParameter;
} }
#if !COREFX #if !NETSTANDARD1_3 && !NETSTANDARD2_0
switch (type.FullName) switch (type.FullName)
{ {
case "Microsoft.SqlServer.Types.SqlGeography": case "Microsoft.SqlServer.Types.SqlGeography":
...@@ -1864,7 +1864,7 @@ private static Exception MultiMapException(IDataRecord reader) ...@@ -1864,7 +1864,7 @@ private static Exception MultiMapException(IDataRecord reader)
/// Internal use only. /// Internal use only.
/// </summary> /// </summary>
/// <param name="value">The object to convert to a character.</param> /// <param name="value">The object to convert to a character.</param>
#if !COREFX #if !NETSTANDARD1_3
[Browsable(false)] [Browsable(false)]
#endif #endif
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
...@@ -1881,7 +1881,7 @@ public static char ReadChar(object value) ...@@ -1881,7 +1881,7 @@ public static char ReadChar(object value)
/// Internal use only. /// Internal use only.
/// </summary> /// </summary>
/// <param name="value">The object to convert to a character.</param> /// <param name="value">The object to convert to a character.</param>
#if !COREFX #if !NETSTANDARD1_3
[Browsable(false)] [Browsable(false)]
#endif #endif
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
...@@ -1900,7 +1900,7 @@ public static char ReadChar(object value) ...@@ -1900,7 +1900,7 @@ public static char ReadChar(object value)
/// <param name="parameters">The parameter collection to search in.</param> /// <param name="parameters">The parameter collection to search in.</param>
/// <param name="command">The command for this fetch.</param> /// <param name="command">The command for this fetch.</param>
/// <param name="name">The name of the parameter to get.</param> /// <param name="name">The name of the parameter to get.</param>
#if !COREFX #if !NETSTANDARD1_3
[Browsable(false)] [Browsable(false)]
#endif #endif
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
...@@ -1958,7 +1958,7 @@ internal static int GetListPaddingExtraCount(int count) ...@@ -1958,7 +1958,7 @@ internal static int GetListPaddingExtraCount(int count)
/// <param name="command">The command to pack parameters for.</param> /// <param name="command">The command to pack parameters for.</param>
/// <param name="namePrefix">The name prefix for these parameters.</param> /// <param name="namePrefix">The name prefix for these parameters.</param>
/// <param name="value">The parameter value can be an <see cref="IEnumerable{T}"/></param> /// <param name="value">The parameter value can be an <see cref="IEnumerable{T}"/></param>
#if !COREFX #if !NETSTANDARD1_3
[Browsable(false)] [Browsable(false)]
#endif #endif
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
...@@ -2257,7 +2257,7 @@ public static string Format(object value) ...@@ -2257,7 +2257,7 @@ public static string Format(object value)
{ {
switch (TypeExtensions.GetTypeCode(value.GetType())) switch (TypeExtensions.GetTypeCode(value.GetType()))
{ {
#if !COREFX #if !NETSTANDARD1_3
case TypeCode.DBNull: case TypeCode.DBNull:
return "null"; return "null";
#endif #endif
...@@ -3080,7 +3080,7 @@ private static LocalBuilder GetTempLocal(ILGenerator il, ref Dictionary<Type, Lo ...@@ -3080,7 +3080,7 @@ private static LocalBuilder GetTempLocal(ILGenerator il, ref Dictionary<Type, Lo
int index = startBound; int index = startBound;
ConstructorInfo specializedConstructor = null; ConstructorInfo specializedConstructor = null;
#if !COREFX #if !NETSTANDARD1_3
bool supportInitialize = false; bool supportInitialize = false;
#endif #endif
Dictionary<Type, LocalBuilder> structLocals = null; Dictionary<Type, LocalBuilder> structLocals = null;
...@@ -3115,7 +3115,7 @@ private static LocalBuilder GetTempLocal(ILGenerator il, ref Dictionary<Type, Lo ...@@ -3115,7 +3115,7 @@ private static LocalBuilder GetTempLocal(ILGenerator il, ref Dictionary<Type, Lo
il.Emit(OpCodes.Newobj, explicitConstr); il.Emit(OpCodes.Newobj, explicitConstr);
il.Emit(OpCodes.Stloc_1); il.Emit(OpCodes.Stloc_1);
#if !COREFX #if !NETSTANDARD1_3
supportInitialize = typeof(ISupportInitialize).IsAssignableFrom(type); supportInitialize = typeof(ISupportInitialize).IsAssignableFrom(type);
if (supportInitialize) if (supportInitialize)
{ {
...@@ -3137,7 +3137,7 @@ private static LocalBuilder GetTempLocal(ILGenerator il, ref Dictionary<Type, Lo ...@@ -3137,7 +3137,7 @@ private static LocalBuilder GetTempLocal(ILGenerator il, ref Dictionary<Type, Lo
{ {
il.Emit(OpCodes.Newobj, ctor); il.Emit(OpCodes.Newobj, ctor);
il.Emit(OpCodes.Stloc_1); il.Emit(OpCodes.Stloc_1);
#if !COREFX #if !NETSTANDARD1_3
supportInitialize = typeof(ISupportInitialize).IsAssignableFrom(type); supportInitialize = typeof(ISupportInitialize).IsAssignableFrom(type);
if (supportInitialize) if (supportInitialize)
{ {
...@@ -3354,7 +3354,7 @@ private static LocalBuilder GetTempLocal(ILGenerator il, ref Dictionary<Type, Lo ...@@ -3354,7 +3354,7 @@ private static LocalBuilder GetTempLocal(ILGenerator il, ref Dictionary<Type, Lo
il.Emit(OpCodes.Newobj, specializedConstructor); il.Emit(OpCodes.Newobj, specializedConstructor);
} }
il.Emit(OpCodes.Stloc_1); // stack is empty il.Emit(OpCodes.Stloc_1); // stack is empty
#if !COREFX #if !NETSTANDARD1_3
if (supportInitialize) if (supportInitialize)
{ {
il.Emit(OpCodes.Ldloc_1); il.Emit(OpCodes.Ldloc_1);
...@@ -3626,7 +3626,7 @@ public static IEqualityComparer<string> ConnectionStringComparer ...@@ -3626,7 +3626,7 @@ public static IEqualityComparer<string> ConnectionStringComparer
private static IEqualityComparer<string> connectionStringComparer = StringComparer.Ordinal; private static IEqualityComparer<string> connectionStringComparer = StringComparer.Ordinal;
#if !COREFX #if !NETSTANDARD1_3
/// <summary> /// <summary>
/// Key used to indicate the type name associated with a DataTable. /// Key used to indicate the type name associated with a DataTable.
/// </summary> /// </summary>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
using System.Data; using System.Data;
using System.Reflection; using System.Reflection;
#if !COREFX #if !NETSTANDARD1_3
namespace Dapper namespace Dapper
{ {
/// <summary> /// <summary>
......
...@@ -7,41 +7,41 @@ namespace Dapper ...@@ -7,41 +7,41 @@ namespace Dapper
internal static class TypeExtensions internal static class TypeExtensions
{ {
public static string Name(this Type type) => public static string Name(this Type type) =>
#if COREFX #if NETSTANDARD1_3 || NETCOREAPP1_0
type.GetTypeInfo().Name; type.GetTypeInfo().Name;
#else #else
type.Name; type.Name;
#endif #endif
public static bool IsValueType(this Type type) => public static bool IsValueType(this Type type) =>
#if COREFX #if NETSTANDARD1_3 || NETCOREAPP1_0
type.GetTypeInfo().IsValueType; type.GetTypeInfo().IsValueType;
#else #else
type.IsValueType; type.IsValueType;
#endif #endif
public static bool IsEnum(this Type type) => public static bool IsEnum(this Type type) =>
#if COREFX #if NETSTANDARD1_3 || NETCOREAPP1_0
type.GetTypeInfo().IsEnum; type.GetTypeInfo().IsEnum;
#else #else
type.IsEnum; type.IsEnum;
#endif #endif
public static bool IsGenericType(this Type type) => public static bool IsGenericType(this Type type) =>
#if COREFX #if NETSTANDARD1_3 || NETCOREAPP1_0
type.GetTypeInfo().IsGenericType; type.GetTypeInfo().IsGenericType;
#else #else
type.IsGenericType; type.IsGenericType;
#endif #endif
public static bool IsInterface(this Type type) => public static bool IsInterface(this Type type) =>
#if COREFX #if NETSTANDARD1_3 || NETCOREAPP1_0
type.GetTypeInfo().IsInterface; type.GetTypeInfo().IsInterface;
#else #else
type.IsInterface; type.IsInterface;
#endif #endif
#if COREFX #if NETSTANDARD1_3 || NETCOREAPP1_0
public static IEnumerable<Attribute> GetCustomAttributes(this Type type, bool inherit) public static IEnumerable<Attribute> GetCustomAttributes(this Type type, bool inherit)
{ {
return type.GetTypeInfo().GetCustomAttributes(inherit); return type.GetTypeInfo().GetCustomAttributes(inherit);
...@@ -85,7 +85,7 @@ public static TypeCode GetTypeCode(Type type) ...@@ -85,7 +85,7 @@ public static TypeCode GetTypeCode(Type type)
public static MethodInfo GetPublicInstanceMethod(this Type type, string name, Type[] types) public static MethodInfo GetPublicInstanceMethod(this Type type, string name, Type[] types)
{ {
#if COREFX #if NETSTANDARD1_3 || NETCOREAPP1_0
var method = type.GetMethod(name, types); var method = type.GetMethod(name, types);
return (method?.IsPublic == true && !method.IsStatic) ? method : null; return (method?.IsPublic == true && !method.IsStatic) ? method : null;
#else #else
......
...@@ -5,7 +5,7 @@ namespace Dapper ...@@ -5,7 +5,7 @@ namespace Dapper
{ {
public static partial class SqlMapper public static partial class SqlMapper
{ {
#if !COREFX #if !NETSTANDARD1_3 && !NETSTANDARD2_0
/// <summary> /// <summary>
/// A type handler for data-types that are supported by the underlying provider, but which need /// A type handler for data-types that are supported by the underlying provider, but which need
/// a well-known UdtTypeName to be specified /// a well-known UdtTypeName to be specified
......
...@@ -30,12 +30,9 @@ ...@@ -30,12 +30,9 @@
<Reference Include="System.Core" Pack="false" /> <Reference Include="System.Core" Pack="false" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' OR '$(TargetFramework)' == 'net451'"> <PropertyGroup Condition=" '$(TargetFramework)' != 'net40'">
<DefineConstants>$(DefineConstants);ASYNC</DefineConstants> <DefineConstants>$(DefineConstants);ASYNC</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<DefineConstants>$(DefineConstants);ASYNC;COREFX</DefineConstants>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="SourceLink.Create.GitHub" Version="2.0.2" PrivateAssets="All" /> <PackageReference Include="SourceLink.Create.GitHub" Version="2.0.2" PrivateAssets="All" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment