Commit 2bde9ac7 authored by Marc Gravell's avatar Marc Gravell

Merge pull request #111 from ssboisen/ssb/cleanup

Cleaned up some nesting
parents 70a9c31b 65235cbb
...@@ -2384,28 +2384,20 @@ public static void SetTypeMap(Type type, ITypeMap map) ...@@ -2384,28 +2384,20 @@ public static void SetTypeMap(Type type, ITypeMap map)
types[i - startBound] = reader.GetFieldType(i); types[i - startBound] = reader.GetFieldType(i);
} }
if (type.IsValueType) var ctor = typeMap.FindConstructor(names, types);
if (ctor == null)
{ {
il.Emit(OpCodes.Ldloca_S, (byte)1); string proposedTypes = "(" + String.Join(", ", types.Select((t, i) => t.FullName + " " + names[i]).ToArray()) + ")";
il.Emit(OpCodes.Initobj, type); throw new InvalidOperationException(String.Format("A parameterless default constructor or one matching signature {0} is required for {1} materialization", proposedTypes, type.FullName));
} }
else
{
var ctor = typeMap.FindConstructor(names, types);
if (ctor == null)
{
string proposedTypes = "(" + String.Join(", ", types.Select((t, i) => t.FullName + " " + names[i]).ToArray()) + ")";
throw new InvalidOperationException(String.Format("A parameterless default constructor or one matching signature {0} is required for {1} materialization", proposedTypes, type.FullName));
}
if (ctor.GetParameters().Length == 0) if (ctor.GetParameters().Length == 0)
{ {
il.Emit(OpCodes.Newobj, ctor); il.Emit(OpCodes.Newobj, ctor);
il.Emit(OpCodes.Stloc_1); il.Emit(OpCodes.Stloc_1);
}
else
specializedConstructor = ctor;
} }
else
specializedConstructor = ctor;
} }
il.BeginExceptionBlock(); il.BeginExceptionBlock();
......
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