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
b2a9db17
Commit
b2a9db17
authored
Mar 03, 2012
by
vosen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for buggy behaviour in the last commit.
parent
2fef85e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
SqlMapper.cs
Dapper/SqlMapper.cs
+13
-11
No files found.
Dapper/SqlMapper.cs
View file @
b2a9db17
...
@@ -1464,12 +1464,12 @@ static List<FieldInfo> GetSettableFields(Type t)
...
@@ -1464,12 +1464,12 @@ static List<FieldInfo> GetSettableFields(Type t)
var
il
=
dm
.
GetILGenerator
();
var
il
=
dm
.
GetILGenerator
();
il
.
DeclareLocal
(
typeof
(
int
));
il
.
DeclareLocal
(
typeof
(
int
));
il
.
DeclareLocal
(
type
);
il
.
DeclareLocal
(
type
);
bool
haveEnumLocal
=
false
;
int
declareLocal
=
1
;
int
enumDeclareLocal
=
-
1
;
il
.
Emit
(
OpCodes
.
Ldc_I4_0
);
il
.
Emit
(
OpCodes
.
Ldc_I4_0
);
il
.
Emit
(
OpCodes
.
Stloc_0
);
il
.
Emit
(
OpCodes
.
Stloc_0
);
var
properties
=
GetSettableProps
(
type
);
var
properties
=
GetSettableProps
(
type
);
var
fields
=
GetSettableFields
(
type
);
var
fields
=
GetSettableFields
(
type
);
int
enumOffset
=
0
;
if
(
length
==
-
1
)
if
(
length
==
-
1
)
{
{
length
=
reader
.
FieldCount
-
startBound
;
length
=
reader
.
FieldCount
-
startBound
;
...
@@ -1518,7 +1518,6 @@ static List<FieldInfo> GetSettableFields(Type t)
...
@@ -1518,7 +1518,6 @@ static List<FieldInfo> GetSettableFields(Type t)
if
(
ctorParameters
.
Length
!=
types
.
Length
)
if
(
ctorParameters
.
Length
!=
types
.
Length
)
continue
;
continue
;
int
i
=
0
;
int
i
=
0
;
int
ctorEnums
=
0
;
for
(;
i
<
ctorParameters
.
Length
;
i
++)
for
(;
i
<
ctorParameters
.
Length
;
i
++)
{
{
if
(!
String
.
Equals
(
ctorParameters
[
i
].
Name
,
names
[
i
],
StringComparison
.
OrdinalIgnoreCase
)
if
(!
String
.
Equals
(
ctorParameters
[
i
].
Name
,
names
[
i
],
StringComparison
.
OrdinalIgnoreCase
)
...
@@ -1529,13 +1528,10 @@ static List<FieldInfo> GetSettableFields(Type t)
...
@@ -1529,13 +1528,10 @@ static List<FieldInfo> GetSettableFields(Type t)
&&
(
ctorParameters
[
i
].
ParameterType
.
IsEnum
&&
ctorParameters
[
i
].
ParameterType
.
GetEnumUnderlyingType
()
!=
types
[
i
])))
&&
(
ctorParameters
[
i
].
ParameterType
.
IsEnum
&&
ctorParameters
[
i
].
ParameterType
.
GetEnumUnderlyingType
()
!=
types
[
i
])))
#endif
#endif
break
;
break
;
if
(
ctorParameters
[
i
].
ParameterType
.
IsEnum
)
ctorEnums
++;
}
}
if
(
i
==
ctorParameters
.
Length
)
if
(
i
==
ctorParameters
.
Length
)
{
{
specializedConstructor
=
ctor
;
specializedConstructor
=
ctor
;
enumOffset
=
ctorEnums
;
break
;
break
;
}
}
}
}
...
@@ -1564,8 +1560,6 @@ static List<FieldInfo> GetSettableFields(Type t)
...
@@ -1564,8 +1560,6 @@ static List<FieldInfo> GetSettableFields(Type t)
bool
first
=
true
;
bool
first
=
true
;
var
allDone
=
il
.
DefineLabel
();
var
allDone
=
il
.
DefineLabel
();
if
(!
haveEnumLocal
)
il
.
DeclareLocal
(
typeof
(
string
));
foreach
(
var
item
in
setters
)
foreach
(
var
item
in
setters
)
{
{
...
@@ -1602,11 +1596,18 @@ static List<FieldInfo> GetSettableFields(Type t)
...
@@ -1602,11 +1596,18 @@ static List<FieldInfo> GetSettableFields(Type t)
if
(
unboxType
.
IsEnum
)
if
(
unboxType
.
IsEnum
)
{
{
if
(
enumDeclareLocal
==
-
1
)
{
il
.
DeclareLocal
(
typeof
(
string
));
declareLocal
++;
enumDeclareLocal
=
declareLocal
;
}
Label
isNotString
=
il
.
DefineLabel
();
Label
isNotString
=
il
.
DefineLabel
();
il
.
Emit
(
OpCodes
.
Dup
);
// stack is now [target][target][value][value]
il
.
Emit
(
OpCodes
.
Dup
);
// stack is now [target][target][value][value]
il
.
Emit
(
OpCodes
.
Isinst
,
typeof
(
string
));
// stack is now [target][target][value-as-object][string or null]
il
.
Emit
(
OpCodes
.
Isinst
,
typeof
(
string
));
// stack is now [target][target][value-as-object][string or null]
il
.
Emit
(
OpCodes
.
Dup
);
// stack is now [target][target][value-as-object][string or null][string or null]
il
.
Emit
(
OpCodes
.
Dup
);
// stack is now [target][target][value-as-object][string or null][string or null]
il
.
Emit
(
OpCodes
.
Stloc
_2
);
// stack is now [target][target][value-as-object][string or null]
il
.
Emit
(
OpCodes
.
Stloc
,
(
short
)
enumDeclareLocal
);
// stack is now [target][target][value-as-object][string or null]
il
.
Emit
(
OpCodes
.
Brfalse_S
,
isNotString
);
// stack is now [target][target][value-as-object]
il
.
Emit
(
OpCodes
.
Brfalse_S
,
isNotString
);
// stack is now [target][target][value-as-object]
il
.
Emit
(
OpCodes
.
Pop
);
// stack is now [target][target]
il
.
Emit
(
OpCodes
.
Pop
);
// stack is now [target][target]
...
@@ -1683,9 +1684,10 @@ static List<FieldInfo> GetSettableFields(Type t)
...
@@ -1683,9 +1684,10 @@ static List<FieldInfo> GetSettableFields(Type t)
if
(
itemType
.
IsValueType
)
if
(
itemType
.
IsValueType
)
{
{
il
.
DeclareLocal
(
itemType
);
il
.
DeclareLocal
(
itemType
);
il
.
Emit
(
OpCodes
.
Ldloca_S
,
(
byte
)(
index
+
enumOffset
+
2
));
declareLocal
++;
il
.
Emit
(
OpCodes
.
Ldloca
,
(
short
)(
declareLocal
));
il
.
Emit
(
OpCodes
.
Initobj
,
itemType
);
il
.
Emit
(
OpCodes
.
Initobj
,
itemType
);
il
.
Emit
(
OpCodes
.
Ldloc
,
(
short
)(
index
+
enumOffset
+
2
));
il
.
Emit
(
OpCodes
.
Ldloc
,
(
short
)(
declareLocal
));
}
}
else
else
{
{
...
...
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