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
cd20c903
Commit
cd20c903
authored
Aug 28, 2019
by
mgravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use LocalBuilder instead of hard-coded _{0|1|2} in Rainbow
parent
61d1061b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
Snapshotter.cs
Dapper.Rainbow/Snapshotter.cs
+15
-15
No files found.
Dapper.Rainbow/Snapshotter.cs
View file @
cd20c903
...
...
@@ -109,13 +109,13 @@ private static bool AreEqual<U>(U first, U second)
var
il
=
dm
.
GetILGenerator
();
// change list
il
.
DeclareLocal
(
typeof
(
List
<
Change
>));
il
.
DeclareLocal
(
typeof
(
Change
));
il
.
DeclareLocal
(
typeof
(
object
));
// boxed change
var
list
=
il
.
DeclareLocal
(
typeof
(
List
<
Change
>));
var
change
=
il
.
DeclareLocal
(
typeof
(
Change
));
var
boxed
=
il
.
DeclareLocal
(
typeof
(
object
));
// boxed change
il
.
Emit
(
OpCodes
.
Newobj
,
typeof
(
List
<
Change
>).
GetConstructor
(
Type
.
EmptyTypes
));
// [list]
il
.
Emit
(
OpCodes
.
Stloc
_0
);
il
.
Emit
(
OpCodes
.
Stloc
,
list
);
foreach
(
var
prop
in
RelevantProperties
())
{
...
...
@@ -138,7 +138,7 @@ private static bool AreEqual<U>(U first, U second)
// [original prop val, current prop val, current prop val boxed]
}
il
.
Emit
(
OpCodes
.
Stloc
_2
);
il
.
Emit
(
OpCodes
.
Stloc
,
boxed
);
// [original prop val, current prop val]
il
.
EmitCall
(
OpCodes
.
Call
,
typeof
(
Snapshot
<
T
>).
GetMethod
(
nameof
(
AreEqual
),
BindingFlags
.
NonPublic
|
BindingFlags
.
Static
).
MakeGenericMethod
(
new
Type
[]
{
prop
.
PropertyType
}),
null
);
...
...
@@ -153,7 +153,7 @@ private static bool AreEqual<U>(U first, U second)
il
.
Emit
(
OpCodes
.
Dup
);
// [change,change]
il
.
Emit
(
OpCodes
.
Stloc
_1
);
il
.
Emit
(
OpCodes
.
Stloc
,
change
);
// [change]
il
.
Emit
(
OpCodes
.
Ldstr
,
prop
.
Name
);
...
...
@@ -161,18 +161,18 @@ private static bool AreEqual<U>(U first, U second)
il
.
Emit
(
OpCodes
.
Callvirt
,
typeof
(
Change
).
GetMethod
(
"set_Name"
));
// []
il
.
Emit
(
OpCodes
.
Ldloc
_1
);
il
.
Emit
(
OpCodes
.
Ldloc
,
change
);
// [change]
il
.
Emit
(
OpCodes
.
Ldloc
_2
);
il
.
Emit
(
OpCodes
.
Ldloc
,
boxed
);
// [change, boxed]
il
.
Emit
(
OpCodes
.
Callvirt
,
typeof
(
Change
).
GetMethod
(
"set_NewValue"
));
// []
il
.
Emit
(
OpCodes
.
Ldloc
_0
);
il
.
Emit
(
OpCodes
.
Ldloc
,
list
);
// [change list]
il
.
Emit
(
OpCodes
.
Ldloc
_1
);
il
.
Emit
(
OpCodes
.
Ldloc
,
change
);
// [change list, change]
il
.
Emit
(
OpCodes
.
Callvirt
,
typeof
(
List
<
Change
>).
GetMethod
(
"Add"
));
// []
...
...
@@ -180,7 +180,7 @@ private static bool AreEqual<U>(U first, U second)
il
.
MarkLabel
(
skip
);
}
il
.
Emit
(
OpCodes
.
Ldloc
_0
);
il
.
Emit
(
OpCodes
.
Ldloc
,
list
);
// [change list]
il
.
Emit
(
OpCodes
.
Ret
);
...
...
@@ -195,14 +195,14 @@ private static bool AreEqual<U>(U first, U second)
var
il
=
dm
.
GetILGenerator
();
il
.
DeclareLocal
(
typeof
(
T
));
var
typed
=
il
.
DeclareLocal
(
typeof
(
T
));
il
.
Emit
(
OpCodes
.
Newobj
,
ctor
);
il
.
Emit
(
OpCodes
.
Stloc
_0
);
il
.
Emit
(
OpCodes
.
Stloc
,
typed
);
foreach
(
var
prop
in
RelevantProperties
())
{
il
.
Emit
(
OpCodes
.
Ldloc
_0
);
il
.
Emit
(
OpCodes
.
Ldloc
,
typed
);
// [clone]
il
.
Emit
(
OpCodes
.
Ldarg_0
);
// [clone, source]
...
...
@@ -213,7 +213,7 @@ private static bool AreEqual<U>(U first, U second)
}
// Load new constructed obj on eval stack -> 1 item on stack
il
.
Emit
(
OpCodes
.
Ldloc
_0
);
il
.
Emit
(
OpCodes
.
Ldloc
,
typed
);
// Return constructed object. --> 0 items on stack
il
.
Emit
(
OpCodes
.
Ret
);
...
...
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