aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-12-21 16:41:07 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-12-21 16:41:07 +0100
commit971cc1b46896f42553874396cae104b43370280b (patch)
tree88466579925dee17e0f5b61277323b02d6ab1a92 /src
parent973cde81486c09c6ede6a607ce766cbec837aa0c (diff)
box valuetype value fetched for init before passing it to convert
Diffstat (limited to 'src')
-rw-r--r--src/Instantiator.cs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/Instantiator.cs b/src/Instantiator.cs
index 490faaad..0ff9e4de 100644
--- a/src/Instantiator.cs
+++ b/src/Instantiator.cs
@@ -855,7 +855,6 @@ namespace Crow
Type origineType = null;
if (piOrig != null)
origineType = piOrig.PropertyType;
-
foreach (MemberAddress ma in bindingCase.Value) {
//first we have to load destination instance onto the stack, it is access
//with graphic tree functions deducted from nodes topology
@@ -878,12 +877,13 @@ namespace Crow
il.Emit (OpCodes.Ldarg_1);
il.Emit (OpCodes.Ldfld, typeof (ValueChangeEventArgs).GetField ("NewValue"));
- if (origineType == null)//property less binding
+ if (origineType == null)//property less binding, no init
emitConvert (il, ma.Property.PropertyType);
else {
- if (origineType != ma.Property.PropertyType)//else, no unboxing required
- emitConvert (ilInit, origineType, ma.Property.PropertyType);
- emitConvert (il, origineType, ma.Property.PropertyType);//unboxing required
+ if (origineType.IsValueType)
+ ilInit.Emit(OpCodes.Box, origineType);
+ emitConvert (ilInit, origineType, ma.Property.PropertyType);
+ emitConvert (il, origineType, ma.Property.PropertyType);
ilInit.Emit (OpCodes.Callvirt, ma.Property.GetSetMethod());//set init value
}
@@ -1101,6 +1101,8 @@ namespace Crow
if (dstType.IsValueType)
il.Emit (OpCodes.Unbox_Any, dstType);
+ else
+ il.Emit (OpCodes.Castclass, dstType);
il.Emit (OpCodes.Br, endConvert);
il.MarkLabel (convert);