Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Dapper
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
Dapper
Commits
ec6faf54
Commit
ec6faf54
authored
May 02, 2015
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for CoreCLR and DNX
parent
a161cb5a
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
332 additions
and
117 deletions
+332
-117
SqlMapper.cs
Dapper NET40/SqlMapper.cs
+13
-13
Program.cs
Dapper.DNX.Tests/Program.cs
+0
-37
project.json
Dapper.DNX.Tests/project.json
+17
-4
project.lock.json
Dapper.DNX.Tests/project.lock.json
+52
-4
Dapper.DNX.sln
Dapper.DNX.sln
+4
-1
project.json
Dapper/project.json
+15
-1
DapperTests NET35.csproj
DapperTests NET35/DapperTests NET35.csproj
+3
-2
DapperTests NET45.csproj
DapperTests NET45/DapperTests NET45.csproj
+2
-2
Assert.cs
Tests/Assert.cs
+4
-0
DapperTests NET40.csproj
Tests/DapperTests NET40.csproj
+3
-2
Program.cs
Tests/Program.cs
+41
-5
Tests.cs
Tests/Tests.cs
+178
-46
No files found.
Dapper NET40/SqlMapper.cs
View file @
ec6faf54
...
...
@@ -7,16 +7,16 @@
*/
#if DNXCORE50
using
IDbDataParameter
=
System
.
Data
.
Common
.
DbParameter
;
using
IDataParameter
=
System
.
Data
.
Common
.
DbParameter
;
using
IDbTransaction
=
System
.
Data
.
Common
.
DbTransaction
;
using
IDbConnection
=
System
.
Data
.
Common
.
DbConnection
;
using
IDbCommand
=
System
.
Data
.
Common
.
DbCommand
;
using
IDataReader
=
System
.
Data
.
Common
.
DbDataReader
;
using
IDataRecord
=
System
.
Data
.
Common
.
DbDataReader
;
using
IDataParameterCollection
=
System
.
Data
.
Common
.
DbParameterCollection
;
using
DataException
=
System
.
InvalidOperationException
;
using
ApplicationException
=
System
.
InvalidOperationException
;
using
IDbDataParameter
=
global
::
System
.
Data
.
Common
.
DbParameter
;
using
IDataParameter
=
global
::
System
.
Data
.
Common
.
DbParameter
;
using
IDbTransaction
=
global
::
System
.
Data
.
Common
.
DbTransaction
;
using
IDbConnection
=
global
::
System
.
Data
.
Common
.
DbConnection
;
using
IDbCommand
=
global
::
System
.
Data
.
Common
.
DbCommand
;
using
IDataReader
=
global
::
System
.
Data
.
Common
.
DbDataReader
;
using
IDataRecord
=
global
::
System
.
Data
.
Common
.
DbDataReader
;
using
IDataParameterCollection
=
global
::
System
.
Data
.
Common
.
DbParameterCollection
;
using
DataException
=
global
::
System
.
InvalidOperationException
;
using
ApplicationException
=
global
::
System
.
InvalidOperationException
;
#endif
using
System
;
...
...
@@ -4907,10 +4907,10 @@ public DynamicParameters Output<T>(T target, Expression<Func<T, object>> express
#if DNXCORE50
lock
(
cache
)
{
#endif
setter
=
(
Action
<
object
,
DynamicParameters
>)
cache
[
lookup
];
#if DNXCORE50
if
(!
cache
.
TryGetValue
(
lookup
,
out
setter
))
setter
=
null
;
}
#else
setter
=
(
Action
<
object
,
DynamicParameters
>)
cache
[
lookup
];
#endif
if
(
setter
!=
null
)
goto
MAKECALLBACK
;
...
...
Dapper.DNX.Tests/Program.cs
deleted
100644 → 0
View file @
a161cb5a
using
System
;
using
System.Linq
;
using
System.Data.SqlClient
;
using
System.Threading.Tasks
;
using
System.Reflection
;
namespace
Dapper.DNX.Tests
{
public
class
Program
{
public
void
Main
()
{
#if DNXCORE50
Console
.
WriteLine
(
"From: {0}"
,
typeof
(
int
).
AssemblyQualifiedName
);
#else
Console
.
WriteLine
(
"Version: {0}"
,
Environment
.
Version
);
#endif
const
string
connectionString
=
"Data Source=.;Initial Catalog=tempdb;Integrated Security=True"
;
using
(
var
conn
=
new
SqlConnection
(
connectionString
))
{
conn
.
Open
();
var
row
=
conn
.
Query
<
Foo
>(
"select @a as X"
,
new
{
a
=
123
}).
Single
();
Console
.
WriteLine
(
row
.
X
);
var
methods
=
typeof
(
Dapper
.
SqlMapper
).
GetMethods
().
Where
(
x
=>
x
.
Name
==
"QueryAsync"
).
ToList
();
#if ASYNC
row
=
conn
.
QueryAsync
<
Foo
>(
"select @a as X"
,
new
{
a
=
123
}).
Result
.
Single
();
#endif
Console
.
WriteLine
(
row
.
X
);
}
}
class
Foo
{
public
int
X
{
get
;
set
;
}
}
}
}
Dapper.DNX.Tests/project.json
View file @
ec6faf54
...
...
@@ -6,26 +6,32 @@
"commands"
:
{
"Dapper.DNX.Tests"
:
"Dapper.DNX.Tests"
},
"compile"
:
[
"../Tests/Tests.cs"
,
"../Tests/Program.cs"
,
"../Tests/Assert.cs"
],
"compilationOptions"
:
{
"define"
:
[
"NOEXTERNALS"
]
},
"frameworks"
:
{
"net45"
:
{
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
],
"warningsAsErrors"
:
true
},
"dependencies"
:
{
"System.Threading.Thread"
:
"4.0.0-beta-22816"
},
"frameworkAssemblies"
:
{
"System.Data"
:
"4.0.0.0"
"System.Data"
:
"4.0.0.0"
,
"System.Xml"
:
"4.0.0.0"
}
},
"net40"
:
{
"dependencies"
:
{
},
"frameworkAssemblies"
:
{
"System.Data"
:
"4.0.0.0"
"System.Data"
:
"4.0.0.0"
,
"System.Xml"
:
"4.0.0.0"
}
},
"dnx451"
:
{
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
],
"warningsAsErrors"
:
true
},
"frameworkAssemblies"
:
{
"System.Data"
:
"4.0.0.0"
"System.Data"
:
"4.0.0.0"
,
"System.Xml"
:
"4.0.0.0"
}
},
...
...
@@ -33,7 +39,14 @@
"compilationOptions"
:
{
"define"
:
[
],
"warningsAsErrors"
:
true
},
"dependencies"
:
{
"System.Console"
:
"4.0.0-beta-*"
,
"System.Reflection"
:
"4.0.10-beta-*"
"System.Reflection"
:
"4.0.10-beta-*"
,
"System.Linq"
:
"4.0.0-beta-*"
,
"System.Data.Common"
:
"4.0.0-beta-*"
,
"System.Data.SqlClient"
:
"4.0.0-beta-*"
,
"System.Threading"
:
"4.0.10-beta-*"
,
"System.Threading.Thread"
:
"4.0.0-beta-*"
,
"System.Reflection.TypeExtensions"
:
"4.0.0-beta-*"
//
"System.Xml"
:
"4.0.10-beta-*"
}
}
}
...
...
Dapper.DNX.Tests/project.lock.json
View file @
ec6faf54
...
...
@@ -16,6 +16,20 @@
"runtime"
:
[
"lib/net45/System.Runtime.dll"
]
},
"System.Threading.Thread/4.0.0-beta-22816"
:
{
"dependencies"
:
{
"System.Runtime"
:
"4.0.20-beta-22816"
},
"frameworkAssemblies"
:
[
"mscorlib"
],
"compile"
:
[
"lib/net45/System.Threading.Thread.dll"
],
"runtime"
:
[
"lib/net45/System.Threading.Thread.dll"
]
}
},
".NETFramework,Version=v4.0"
:
{},
...
...
@@ -325,6 +339,17 @@
"lib/aspnetcore50/System.Threading.Tasks.dll"
]
},
"System.Threading.Thread/4.0.0-beta-22816"
:
{
"dependencies"
:
{
"System.Runtime"
:
"4.0.20-beta-22816"
},
"compile"
:
[
"lib/contract/System.Threading.Thread.dll"
],
"runtime"
:
[
"lib/aspnetcore50/System.Threading.Thread.dll"
]
},
"System.Xml.ReaderWriter/4.0.10-beta-22816"
:
{
"dependencies"
:
{
"System.IO"
:
"4.0.10-beta-22816"
,
...
...
@@ -669,6 +694,19 @@
"lib/portable-wpa81+wp80+win80+net45+aspnetcore50/System.Threading.Tasks.dll"
]
},
"System.Threading.Thread/4.0.0-beta-22816"
:
{
"sha512"
:
"hq1pNoES0jEKslftDhBeJnRUBSjEepiya+39oH/7yCvOp4xMnXHlWe9G7ZS/dg2n4k+3VY21AUifisybcFjcCQ=="
,
"files"
:
[
"License.rtf"
,
"System.Threading.Thread.4.0.0-beta-22816.nupkg"
,
"System.Threading.Thread.4.0.0-beta-22816.nupkg.sha512"
,
"System.Threading.Thread.nuspec"
,
"lib/aspnetcore50/System.Threading.Thread.dll"
,
"lib/contract/System.Threading.Thread.dll"
,
"lib/net45/System.Threading.Thread.dll"
,
"lib/portable-wpa81+wp80+win80+net45+aspnetcore50/System.Threading.Thread.dll"
]
},
"System.Xml.ReaderWriter/4.0.10-beta-22816"
:
{
"sha512"
:
"G0aLPtC/phTfiJPwe0VA3tB3x8YFQ1dHFuE1xaHNr9eQm/AfBp4Pk+fn3s7ABJDus/T89EtIHQ9C+O6VmqXIQQ=="
,
"files"
:
[
...
...
@@ -688,17 +726,27 @@
"Dapper >= 1.41-*"
],
".NETFramework,Version=v4.5"
:
[
"framework/System.Data >= 4.0.0.0"
"System.Threading.Thread >= 4.0.0-beta-22816"
,
"framework/System.Data >= 4.0.0.0"
,
"framework/System.Xml >= 4.0.0.0"
],
".NETFramework,Version=v4.0"
:
[
"framework/System.Data >= 4.0.0.0"
"framework/System.Data >= 4.0.0.0"
,
"framework/System.Xml >= 4.0.0.0"
],
"DNX,Version=v4.5.1"
:
[
"framework/System.Data >= 4.0.0.0"
"framework/System.Data >= 4.0.0.0"
,
"framework/System.Xml >= 4.0.0.0"
],
"DNXCore,Version=v5.0"
:
[
"System.Console >= 4.0.0-beta-*"
,
"System.Reflection >= 4.0.10-beta-*"
"System.Reflection >= 4.0.10-beta-*"
,
"System.Linq >= 4.0.0-beta-*"
,
"System.Data.Common >= 4.0.0-beta-*"
,
"System.Data.SqlClient >= 4.0.0-beta-*"
,
"System.Threading >= 4.0.10-beta-*"
,
"System.Threading.Thread >= 4.0.0-beta-*"
,
"System.Reflection.TypeExtensions >= 4.0.0-beta-*"
]
}
}
\ No newline at end of file
Dapper.DNX.sln
View file @
ec6faf54
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22
728
.1
VisualStudioVersion = 14.0.22
823
.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Dapper", "Dapper\Dapper.xproj", "{088D8CC4-E71E-44B6-9B87-4060B043983D}"
EndProject
...
...
@@ -9,8 +9,11 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Dapper.DNX.Tests", "Dapper.
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{03340C6E-4176-4C42-9C76-D5DFC79D1A22}"
ProjectSection(SolutionItems) = preProject
Tests\Assert.cs = Tests\Assert.cs
Tests\Program.cs = Tests\Program.cs
Dapper NET40\SqlMapper.cs = Dapper NET40\SqlMapper.cs
Dapper NET45\SqlMapperAsync.cs = Dapper NET45\SqlMapperAsync.cs
Tests\Tests.cs = Tests\Tests.cs
EndProjectSection
EndProject
Global
...
...
Dapper/project.json
View file @
ec6faf54
{
"authors"
:
[
"Sam Saffron"
,
"Marc Gravell"
],
"owners"
:
[
"Sam Saffron"
,
"Marc Gravell"
],
"projectUrl"
:
"https://github.com/StackExchange/dapper-dot-net"
,
"licenseUrl"
:
"http://www.apache.org/licenses/LICENSE-2.0"
,
"summary"
:
"A high performance Micro-ORM"
,
"description"
:
"A high performance Micro-ORM supporting Sql Server, MySQL, Sqlite, SqlCE, Firebird etc.."
,
"version"
:
"1.41-beta"
,
"version"
:
"1.41-beta
2
"
,
"compile"
:
[
"../Dapper NET40/*.cs"
,
"../Dapper NET45/*.cs"
],
"title"
:
"Dapper dot net"
,
"tags"
:
[
"orm"
,
"sql"
,
"micro-orm"
],
"frameworks"
:
{
"net45"
:
{
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
],
"warningsAsErrors"
:
true
},
...
...
@@ -21,6 +27,14 @@
"System.Data"
:
"4.0.0.0"
}
},
//
"net35"
:
{
//
"compilationOptions"
:
{
"warningsAsErrors"
:
true
,
"languageVersion"
:
"csharp3"
,
"define"
:
[
"CSHARP30"
]
},
//
"dependencies"
:
{
//
},
//
"frameworkAssemblies"
:
{
//
"System.Data"
:
"4.0.0.0"
//
}
//
},
"dnx451"
:
{
"compilationOptions"
:
{
"define"
:
[
"ASYNC"
],
"warningsAsErrors"
:
true
},
"dependencies"
:
{
...
...
DapperTests NET35/DapperTests NET35.csproj
View file @
ec6faf54
...
...
@@ -21,7 +21,7 @@
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
TRACE;DEBUG;NET35
</DefineConstants>
<DefineConstants>
TRACE;DEBUG;NET35
EXTERNALS
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
...
...
@@ -30,9 +30,10 @@
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE;NET35
</DefineConstants>
<DefineConstants>
TRACE;NET35
EXTERNALS
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<AllowUnsafeBlocks>
true
</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"System"
/>
...
...
DapperTests NET45/DapperTests NET45.csproj
View file @
ec6faf54
...
...
@@ -19,7 +19,7 @@
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<DefineConstants>
TRACE;DEBUG;EXTERNALS
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
...
...
@@ -28,7 +28,7 @@
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE
</DefineConstants>
<DefineConstants>
TRACE
;EXTERNALS
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
...
...
Tests/Assert.cs
View file @
ec6faf54
...
...
@@ -3,6 +3,10 @@
using
System.Linq
;
using
System.Text
;
#if DNXCORE50
using
ApplicationException
=
global
::
System
.
InvalidOperationException
;
#endif
namespace
SqlMapper
{
static
class
Assert
...
...
Tests/DapperTests NET40.csproj
View file @
ec6faf54
...
...
@@ -22,7 +22,7 @@
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<DefineConstants>
TRACE;DEBUG;EXTERNALS PERF
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<Prefer32Bit>
false
</Prefer32Bit>
...
...
@@ -32,10 +32,11 @@
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE
</DefineConstants>
<DefineConstants>
TRACE
;EXTERNALS PERF
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<Prefer32Bit>
false
</Prefer32Bit>
<AllowUnsafeBlocks>
false
</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"BLToolkit.4"
>
...
...
Tests/Program.cs
View file @
ec6faf54
...
...
@@ -6,11 +6,15 @@
namespace
SqlMapper
{
#if EXTERNALS
[
ServiceStack
.
DataAnnotations
.
Alias
(
"Posts"
)]
[
Soma
.
Core
.
Table
(
Name
=
"Posts"
)]
#endif
public
class
Post
{
#if EXTERNALS
[
Soma
.
Core
.
Id
(
Soma
.
Core
.
IdKind
.
Identity
)]
#endif
public
int
Id
{
get
;
set
;
}
public
string
Text
{
get
;
set
;
}
public
DateTime
CreationDate
{
get
;
set
;
}
...
...
@@ -42,10 +46,14 @@ public static SqlConnection GetOpenConnection()
static
void
RunPerformanceTests
()
{
#if PERF
var
test
=
new
PerformanceTests
();
const
int
iterations
=
500
;
Console
.
WriteLine
(
"Running {0} iterations that load up a post entity"
,
iterations
);
test
.
Run
(
iterations
);
#else
Console
.
WriteLine
(
"Performance tests have not been built; add the PERF symbol"
);
#endif
}
static
void
Main
()
...
...
@@ -53,13 +61,18 @@ static void Main()
#if DEBUG
RunTests
();
#else
#else
EnsureDBSetup
();
RunPerformanceTests
();
#endif
Console
.
WriteLine
(
"(end of tests; press any key)"
);
#if DNXCORE50
Console
.
WriteLine
(
"(end of tests; press return)"
);
Console
.
ReadLine
();
#else
Console
.
WriteLine
(
"(end of tests; press any key)"
);
Console
.
ReadKey
();
#endif
}
private
static
void
EnsureDBSetup
()
...
...
@@ -110,27 +123,46 @@ insert Posts ([Text],CreationDate, LastChangeDate) values (replicate('x', 2000),
cmd
.
ExecuteNonQuery
();
}
}
private
static
bool
HasAttribute
<
T
>(
MemberInfo
member
)
where
T
:
Attribute
{
#if DNXCORE50
return
member
.
CustomAttributes
.
Any
(
x
=>
x
.
AttributeType
==
typeof
(
T
));
#else
return
Attribute
.
IsDefined
(
member
,
typeof
(
T
),
true
);
#endif
}
private
static
void
RunTests
()
{
var
tester
=
new
Tests
();
int
fail
=
0
;
int
fail
=
0
,
skip
=
0
,
pass
=
0
;
MethodInfo
[]
methods
=
typeof
(
Tests
).
GetMethods
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
|
BindingFlags
.
DeclaredOnly
);
var
activeTests
=
methods
.
Where
(
m
=>
Attribute
.
IsDefined
(
m
,
typeof
(
ActiveTestAttribute
)
)).
ToArray
();
var
activeTests
=
methods
.
Where
(
m
=>
HasAttribute
<
ActiveTestAttribute
>(
m
)).
ToArray
();
if
(
activeTests
.
Length
!=
0
)
methods
=
activeTests
;
List
<
string
>
failNames
=
new
List
<
string
>();
foreach
(
var
method
in
methods
)
{
if
(
HasAttribute
<
SkipTestAttribute
>(
method
))
{
Console
.
Write
(
"Skipping "
+
method
.
Name
);
skip
++;
continue
;
}
Console
.
Write
(
"Running "
+
method
.
Name
);
try
{
method
.
Invoke
(
tester
,
null
);
Console
.
WriteLine
(
" - OK!"
);
pass
++;
}
catch
(
TargetInvocationException
tie
)
{
fail
++;
Console
.
WriteLine
(
" - "
+
tie
.
InnerException
.
Message
);
failNames
.
Add
(
method
.
Name
);
if
(
tie
.
InnerException
is
TypeInitializationException
)
{
Console
.
WriteLine
(
"> "
+
tie
.
InnerException
.
InnerException
.
Message
);
}
}
catch
(
Exception
ex
)
{
...
...
@@ -139,13 +171,15 @@ private static void RunTests()
}
}
Console
.
WriteLine
();
Console
.
WriteLine
(
"Passed: {0}, Failed: {1}, Skipped: {2}"
,
pass
,
fail
,
skip
);
if
(
fail
==
0
)
{
Console
.
WriteLine
(
"(all tests successful)"
);
}
else
{
Console
.
WriteLine
(
"
#### FAILED: {0}"
,
fail
);
Console
.
WriteLine
(
"
Failures:"
);
foreach
(
var
failName
in
failNames
)
{
Console
.
WriteLine
(
failName
);
...
...
@@ -156,5 +190,7 @@ private static void RunTests()
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
false
)]
public
sealed
class
ActiveTestAttribute
:
Attribute
{}
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
false
)]
public
sealed
class
SkipTestAttribute
:
Attribute
{
}
}
Tests/Tests.cs
View file @
ec6faf54
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment