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
dc6b077f
Commit
dc6b077f
authored
May 02, 2015
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Found a few framework bugs (recorded), and fixed internal properties mapping
parent
8d65caba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
20 deletions
+80
-20
SqlMapper.cs
Dapper NET40/SqlMapper.cs
+18
-8
project.json
Dapper/project.json
+1
-1
Program.cs
Tests/Program.cs
+35
-9
Tests.cs
Tests/Tests.cs
+26
-2
No files found.
Dapper NET40/SqlMapper.cs
View file @
dc6b077f
...
@@ -5313,18 +5313,28 @@ public DefaultTypeMap(Type type)
...
@@ -5313,18 +5313,28 @@ public DefaultTypeMap(Type type)
_properties
=
GetSettableProps
(
type
);
_properties
=
GetSettableProps
(
type
);
_type
=
type
;
_type
=
type
;
}
}
#if DNXCORE50
static
bool
IsParameterMatch
(
ParameterInfo
[]
x
,
ParameterInfo
[]
y
)
{
if
(
ReferenceEquals
(
x
,
y
))
return
true
;
if
(
x
==
null
||
y
==
null
)
return
false
;
if
(
x
.
Length
!=
y
.
Length
)
return
false
;
for
(
int
i
=
0
;
i
<
x
.
Length
;
i
++)
if
(
x
[
i
].
ParameterType
!=
y
[
i
].
ParameterType
)
return
false
;
return
true
;
}
#endif
internal
static
MethodInfo
GetPropertySetter
(
PropertyInfo
propertyInfo
,
Type
type
)
internal
static
MethodInfo
GetPropertySetter
(
PropertyInfo
propertyInfo
,
Type
type
)
{
{
return
propertyInfo
.
DeclaringType
==
type
?
if
(
propertyInfo
.
DeclaringType
==
type
)
return
propertyInfo
.
GetSetMethod
(
true
);
propertyInfo
.
GetSetMethod
(
true
)
:
#if DNXCORE50
#if DNXCORE50
propertyInfo
.
DeclaringType
.
GetProperty
(
return
propertyInfo
.
DeclaringType
.
GetProperties
(
BindingFlags
.
Public
|
BindingFlags
.
NonPublic
|
BindingFlags
.
Instance
)
propertyInfo
.
Name
,
propertyInfo
.
PropertyType
,
.
Single
(
x
=>
x
.
Name
==
propertyInfo
.
Name
propertyInfo
.
GetIndexParameters
().
Select
(
p
=>
p
.
ParameterType
).
ToArray
()
&&
x
.
PropertyType
==
propertyInfo
.
PropertyType
).
GetSetMethod
(
true
);
&&
IsParameterMatch
(
x
.
GetIndexParameters
(),
propertyInfo
.
GetIndexParameters
())
).
GetSetMethod
(
true
);
#else
#else
propertyInfo
.
DeclaringType
.
GetProperty
(
return
propertyInfo
.
DeclaringType
.
GetProperty
(
propertyInfo
.
Name
,
propertyInfo
.
Name
,
BindingFlags
.
Public
|
BindingFlags
.
NonPublic
|
BindingFlags
.
Instance
,
BindingFlags
.
Public
|
BindingFlags
.
NonPublic
|
BindingFlags
.
Instance
,
Type
.
DefaultBinder
,
Type
.
DefaultBinder
,
...
...
Dapper/project.json
View file @
dc6b077f
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
"licenseUrl"
:
"http://www.apache.org/licenses/LICENSE-2.0"
,
"licenseUrl"
:
"http://www.apache.org/licenses/LICENSE-2.0"
,
"summary"
:
"A high performance Micro-ORM"
,
"summary"
:
"A high performance Micro-ORM"
,
"description"
:
"A high performance Micro-ORM supporting Sql Server, MySQL, Sqlite, SqlCE, Firebird etc.."
,
"description"
:
"A high performance Micro-ORM supporting Sql Server, MySQL, Sqlite, SqlCE, Firebird etc.."
,
"version"
:
"1.41-beta
2
"
,
"version"
:
"1.41-beta
3
"
,
"compile"
:
[
"../Dapper NET40/*.cs"
,
"../Dapper NET45/*.cs"
],
"compile"
:
[
"../Dapper NET40/*.cs"
,
"../Dapper NET45/*.cs"
],
"title"
:
"Dapper dot net"
,
"title"
:
"Dapper dot net"
,
"tags"
:
[
"orm"
,
"sql"
,
"micro-orm"
],
"tags"
:
[
"orm"
,
"sql"
,
"micro-orm"
],
...
...
Tests/Program.cs
View file @
dc6b077f
...
@@ -139,7 +139,7 @@ insert Posts ([Text],CreationDate, LastChangeDate) values (replicate('x', 2000),
...
@@ -139,7 +139,7 @@ insert Posts ([Text],CreationDate, LastChangeDate) values (replicate('x', 2000),
private
static
void
RunTests
()
private
static
void
RunTests
()
{
{
var
tester
=
new
Tests
();
var
tester
=
new
Tests
();
int
fail
=
0
,
skip
=
0
,
pass
=
0
;
int
fail
=
0
,
skip
=
0
,
pass
=
0
,
frameworkFail
=
0
;
MethodInfo
[]
methods
=
typeof
(
Tests
).
GetMethods
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
|
BindingFlags
.
DeclaredOnly
);
MethodInfo
[]
methods
=
typeof
(
Tests
).
GetMethods
(
BindingFlags
.
Public
|
BindingFlags
.
Instance
|
BindingFlags
.
DeclaredOnly
);
var
activeTests
=
methods
.
Where
(
m
=>
HasAttribute
<
ActiveTestAttribute
>(
m
)).
ToArray
();
var
activeTests
=
methods
.
Where
(
m
=>
HasAttribute
<
ActiveTestAttribute
>(
m
)).
ToArray
();
if
(
activeTests
.
Length
!=
0
)
methods
=
activeTests
;
if
(
activeTests
.
Length
!=
0
)
methods
=
activeTests
;
...
@@ -152,31 +152,49 @@ private static void RunTests()
...
@@ -152,31 +152,49 @@ private static void RunTests()
skip
++;
skip
++;
continue
;
continue
;
}
}
bool
expectFrameworkFail
=
HasAttribute
<
FrameworkFail
>(
method
);
Console
.
Write
(
"Running "
+
method
.
Name
);
Console
.
Write
(
"Running "
+
method
.
Name
);
try
try
{
{
method
.
Invoke
(
tester
,
null
);
method
.
Invoke
(
tester
,
null
);
Console
.
WriteLine
(
" - OK!"
);
if
(
expectFrameworkFail
)
pass
++;
{
Console
.
WriteLine
(
" - was expected to framework-fail, but didn't"
);
fail
++;
failNames
.
Add
(
method
.
Name
);
}
else
{
Console
.
WriteLine
(
" - OK!"
);
pass
++;
}
}
catch
(
TargetInvocationException
tie
)
}
catch
(
TargetInvocationException
tie
)
{
{
fail
++;
Console
.
WriteLine
(
" - "
+
tie
.
InnerException
.
Message
);
Console
.
WriteLine
(
" - "
+
tie
.
InnerException
.
Message
);
failNames
.
Add
(
method
.
Name
);
if
(
expectFrameworkFail
)
if
(
tie
.
InnerException
is
TypeInitializationException
)
{
{
Console
.
WriteLine
(
"> "
+
tie
.
InnerException
.
InnerException
.
Message
);
frameworkFail
++;
}
else
{
fail
++;
failNames
.
Add
(
method
.
Name
);
if
(
tie
.
InnerException
is
TypeInitializationException
)
{
Console
.
WriteLine
(
"> "
+
tie
.
InnerException
.
InnerException
.
Message
);
}
}
}
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
{
fail
++;
fail
++;
Console
.
WriteLine
(
" - "
+
ex
.
Message
);
Console
.
WriteLine
(
" - "
+
ex
.
Message
);
failNames
.
Add
(
method
.
Name
);
}
}
}
}
Console
.
WriteLine
();
Console
.
WriteLine
();
Console
.
WriteLine
(
"Passed: {0}, Failed: {1}, Skipped: {2}
"
,
pass
,
fail
,
skip
);
Console
.
WriteLine
(
"Passed: {0}, Failed: {1}, Skipped: {2}
, Framework-fail: {3}"
,
pass
,
fail
,
skip
,
frameworkFail
);
if
(
fail
==
0
)
if
(
fail
==
0
)
{
{
Console
.
WriteLine
(
"(all tests successful)"
);
Console
.
WriteLine
(
"(all tests successful)"
);
...
@@ -197,4 +215,12 @@ public sealed class ActiveTestAttribute : Attribute {}
...
@@ -197,4 +215,12 @@ public sealed class ActiveTestAttribute : Attribute {}
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
false
)]
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
false
)]
public
sealed
class
SkipTestAttribute
:
Attribute
{
}
public
sealed
class
SkipTestAttribute
:
Attribute
{
}
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
false
)]
public
sealed
class
FrameworkFail
:
Attribute
{
public
FrameworkFail
(
string
url
)
{
this
.
Url
=
url
;
}
public
string
Url
{
get
;
private
set
;
}
}
}
}
Tests/Tests.cs
View file @
dc6b077f
...
@@ -281,6 +281,7 @@ public void TestNoDefaultConstructorBinary()
...
@@ -281,6 +281,7 @@ public void TestNoDefaultConstructorBinary()
output
.
ToArray
().
IsSequenceEqualTo
(
orig
);
output
.
ToArray
().
IsSequenceEqualTo
(
orig
);
}
}
#endif
#endif
// http://stackoverflow.com/q/8593871
// http://stackoverflow.com/q/8593871
public
void
TestAbstractInheritance
()
public
void
TestAbstractInheritance
()
{
{
...
@@ -3180,6 +3181,22 @@ enum AnotherEnum : byte
...
@@ -3180,6 +3181,22 @@ enum AnotherEnum : byte
A
=
2
,
A
=
2
,
B
=
1
B
=
1
}
}
#if DNXCORE50
[
FrameworkFail
(
"https://github.com/dotnet/corefx/issues/1613"
)]
#endif
public
void
AdoNetEnumValue
()
{
using
(
var
cmd
=
connection
.
CreateCommand
())
{
cmd
.
CommandText
=
"select @foo"
;
cmd
.
Parameters
.
AddWithValue
(
"@foo"
,
AnEnum
.
B
);
object
value
=
cmd
.
ExecuteScalar
();
AnEnum
val
=
(
AnEnum
)
value
;
val
.
IsEqualTo
(
AnEnum
.
B
);
}
}
public
void
LiteralReplacementEnumAndString
()
public
void
LiteralReplacementEnumAndString
()
{
{
var
args
=
new
{
x
=
AnEnum
.
B
,
y
=
123.45
M
,
z
=
AnotherEnum
.
A
};
var
args
=
new
{
x
=
AnEnum
.
B
,
y
=
123.45
M
,
z
=
AnotherEnum
.
A
};
...
@@ -3191,6 +3208,9 @@ public void LiteralReplacementEnumAndString()
...
@@ -3191,6 +3208,9 @@ public void LiteralReplacementEnumAndString()
y
.
Equals
(
123.45
M
);
y
.
Equals
(
123.45
M
);
z
.
Equals
(
AnotherEnum
.
A
);
z
.
Equals
(
AnotherEnum
.
A
);
}
}
#if DNXCORE50
[
FrameworkFail
(
"https://github.com/dotnet/corefx/issues/1613"
)]
#endif
public
void
LiteralReplacementDynamicEnumAndString
()
public
void
LiteralReplacementDynamicEnumAndString
()
{
{
var
args
=
new
DynamicParameters
();
var
args
=
new
DynamicParameters
();
...
@@ -4326,7 +4346,9 @@ public void SO29343103_UtcDates()
...
@@ -4326,7 +4346,9 @@ public void SO29343103_UtcDates()
var
delta
=
returned
-
date
;
var
delta
=
returned
-
date
;
Assert
.
IsTrue
(
delta
.
TotalMilliseconds
>=
-
1
&&
delta
.
TotalMilliseconds
<=
1
);
Assert
.
IsTrue
(
delta
.
TotalMilliseconds
>=
-
1
&&
delta
.
TotalMilliseconds
<=
1
);
}
}
#if DNXCORE50
[
FrameworkFail
(
"https://github.com/dotnet/corefx/issues/1612"
)]
#endif
public
void
Issue261_Decimals
()
public
void
Issue261_Decimals
()
{
{
var
parameters
=
new
DynamicParameters
();
var
parameters
=
new
DynamicParameters
();
...
@@ -4336,7 +4358,9 @@ public void Issue261_Decimals()
...
@@ -4336,7 +4358,9 @@ public void Issue261_Decimals()
var
c
=
parameters
.
Get
<
Decimal
>(
"c"
);
var
c
=
parameters
.
Get
<
Decimal
>(
"c"
);
c
.
IsEqualTo
(
11.884
M
);
c
.
IsEqualTo
(
11.884
M
);
}
}
#if DNXCORE50
[
FrameworkFail
(
"https://github.com/dotnet/corefx/issues/1612"
)]
#endif
public
void
Issue261_Decimals_ADONET_SetViaBaseClass
()
public
void
Issue261_Decimals_ADONET_SetViaBaseClass
()
{
{
Issue261_Decimals_ADONET
(
true
);
Issue261_Decimals_ADONET
(
true
);
...
...
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