Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Dapper
提交
dc6b077f
D
Dapper
项目概览
int
/
Dapper
11 个月 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Dapper
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dc6b077f
编写于
5月 02, 2015
作者:
M
Marc Gravell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Found a few framework bugs (recorded), and fixed internal properties mapping
上级
8d65caba
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
80 addition
and
20 deletion
+80
-20
Dapper NET40/SqlMapper.cs
Dapper NET40/SqlMapper.cs
+18
-8
Dapper/project.json
Dapper/project.json
+1
-1
Tests/Program.cs
Tests/Program.cs
+35
-9
Tests/Tests.cs
Tests/Tests.cs
+26
-2
未找到文件。
Dapper NET40/SqlMapper.cs
浏览文件 @
dc6b077f
...
...
@@ -5313,18 +5313,28 @@ public DefaultTypeMap(Type type)
_properties
=
GetSettableProps
(
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
)
{
return
propertyInfo
.
DeclaringType
==
type
?
propertyInfo
.
GetSetMethod
(
true
)
:
if
(
propertyInfo
.
DeclaringType
==
type
)
return
propertyInfo
.
GetSetMethod
(
true
);
#if DNXCORE50
propertyInfo
.
DeclaringType
.
GetProperty
(
propertyInfo
.
Name
,
propertyInfo
.
PropertyType
,
propertyInfo
.
GetIndexParameters
().
Select
(
p
=>
p
.
ParameterType
).
ToArray
()
).
GetSetMethod
(
true
);
return
propertyInfo
.
DeclaringType
.
GetProperties
(
BindingFlags
.
Public
|
BindingFlags
.
NonPublic
|
BindingFlags
.
Instance
)
.
Single
(
x
=>
x
.
Name
==
propertyInfo
.
Name
&&
x
.
PropertyType
==
propertyInfo
.
PropertyType
&&
IsParameterMatch
(
x
.
GetIndexParameters
(),
propertyInfo
.
GetIndexParameters
())
).
GetSetMethod
(
true
);
#else
propertyInfo
.
DeclaringType
.
GetProperty
(
return
propertyInfo
.
DeclaringType
.
GetProperty
(
propertyInfo
.
Name
,
BindingFlags
.
Public
|
BindingFlags
.
NonPublic
|
BindingFlags
.
Instance
,
Type
.
DefaultBinder
,
...
...
Dapper/project.json
浏览文件 @
dc6b077f
...
...
@@ -5,7 +5,7 @@
"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
2
"
,
"version"
:
"1.41-beta
3
"
,
"compile"
:
[
"../Dapper NET40/*.cs"
,
"../Dapper NET45/*.cs"
],
"title"
:
"Dapper dot net"
,
"tags"
:
[
"orm"
,
"sql"
,
"micro-orm"
],
...
...
Tests/Program.cs
浏览文件 @
dc6b077f
...
...
@@ -139,7 +139,7 @@ insert Posts ([Text],CreationDate, LastChangeDate) values (replicate('x', 2000),
private
static
void
RunTests
()
{
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
);
var
activeTests
=
methods
.
Where
(
m
=>
HasAttribute
<
ActiveTestAttribute
>(
m
)).
ToArray
();
if
(
activeTests
.
Length
!=
0
)
methods
=
activeTests
;
...
...
@@ -152,31 +152,49 @@ private static void RunTests()
skip
++;
continue
;
}
bool
expectFrameworkFail
=
HasAttribute
<
FrameworkFail
>(
method
);
Console
.
Write
(
"Running "
+
method
.
Name
);
try
{
method
.
Invoke
(
tester
,
null
);
Console
.
WriteLine
(
" - OK!"
);
pass
++;
if
(
expectFrameworkFail
)
{
Console
.
WriteLine
(
" - was expected to framework-fail, but didn't"
);
fail
++;
failNames
.
Add
(
method
.
Name
);
}
else
{
Console
.
WriteLine
(
" - OK!"
);
pass
++;
}
}
catch
(
TargetInvocationException
tie
)
{
fail
++;
Console
.
WriteLine
(
" - "
+
tie
.
InnerException
.
Message
);
failNames
.
Add
(
method
.
Name
);
if
(
tie
.
InnerException
is
TypeInitializationException
)
if
(
expectFrameworkFail
)
{
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
)
{
fail
++;
Console
.
WriteLine
(
" - "
+
ex
.
Message
);
failNames
.
Add
(
method
.
Name
);
}
}
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
)
{
Console
.
WriteLine
(
"(all tests successful)"
);
...
...
@@ -197,4 +215,12 @@ public sealed class ActiveTestAttribute : Attribute {}
[
AttributeUsage
(
AttributeTargets
.
Method
,
AllowMultiple
=
false
)]
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
浏览文件 @
dc6b077f
...
...
@@ -281,6 +281,7 @@ public void TestNoDefaultConstructorBinary()
output
.
ToArray
().
IsSequenceEqualTo
(
orig
);
}
#endif
// http://stackoverflow.com/q/8593871
public
void
TestAbstractInheritance
()
{
...
...
@@ -3180,6 +3181,22 @@ enum AnotherEnum : byte
A
=
2
,
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
()
{
var
args
=
new
{
x
=
AnEnum
.
B
,
y
=
123.45
M
,
z
=
AnotherEnum
.
A
};
...
...
@@ -3191,6 +3208,9 @@ public void LiteralReplacementEnumAndString()
y
.
Equals
(
123.45
M
);
z
.
Equals
(
AnotherEnum
.
A
);
}
#if DNXCORE50
[
FrameworkFail
(
"https://github.com/dotnet/corefx/issues/1613"
)]
#endif
public
void
LiteralReplacementDynamicEnumAndString
()
{
var
args
=
new
DynamicParameters
();
...
...
@@ -4326,7 +4346,9 @@ public void SO29343103_UtcDates()
var
delta
=
returned
-
date
;
Assert
.
IsTrue
(
delta
.
TotalMilliseconds
>=
-
1
&&
delta
.
TotalMilliseconds
<=
1
);
}
#if DNXCORE50
[
FrameworkFail
(
"https://github.com/dotnet/corefx/issues/1612"
)]
#endif
public
void
Issue261_Decimals
()
{
var
parameters
=
new
DynamicParameters
();
...
...
@@ -4336,7 +4358,9 @@ public void Issue261_Decimals()
var
c
=
parameters
.
Get
<
Decimal
>(
"c"
);
c
.
IsEqualTo
(
11.884
M
);
}
#if DNXCORE50
[
FrameworkFail
(
"https://github.com/dotnet/corefx/issues/1612"
)]
#endif
public
void
Issue261_Decimals_ADONET_SetViaBaseClass
()
{
Issue261_Decimals_ADONET
(
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录