Commit c7dd5f0d authored by vosen's avatar vosen

Fix broken IL when generating default value-typed values.

parent 7fe87dc6
...@@ -1665,10 +1665,17 @@ static List<FieldInfo> GetSettableFields(Type t) ...@@ -1665,10 +1665,17 @@ static List<FieldInfo> GetSettableFields(Type t)
{ {
Type itemType = item.Property != null ? item.Property.Type : item.Field.FieldType; Type itemType = item.Property != null ? item.Property.Type : item.Field.FieldType;
if (itemType.IsValueType) if (itemType.IsValueType)
{
il.DeclareLocal(itemType);
il.Emit(OpCodes.Ldloca_S, (byte)(index + 2));
il.Emit(OpCodes.Initobj, itemType); il.Emit(OpCodes.Initobj, itemType);
il.Emit(OpCodes.Ldloc, (short)(index + 2));
}
else else
{
il.Emit(OpCodes.Ldnull); il.Emit(OpCodes.Ldnull);
} }
}
else else
{ {
il.Emit(OpCodes.Pop); // stack is now [target][target] il.Emit(OpCodes.Pop); // stack is now [target][target]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment