Commit 317890e0 authored by Marc Gravell's avatar Marc Gravell

FIX: work with non-public constructors

parent d154fd9a
......@@ -1331,7 +1331,7 @@ static List<FieldInfo> GetSettableFields(Type t)
il.BeginExceptionBlock();
// stack is empty
il.Emit(OpCodes.Newobj, typeof(T).GetConstructor(Type.EmptyTypes)); // stack is now [target]
il.Emit(OpCodes.Newobj, typeof(T).GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null)); // stack is now [target]
bool first = true;
var allDone = il.DefineLabel();
foreach (var item in setters)
......
......@@ -1038,6 +1038,18 @@ class WithBinary
{
public System.Data.Linq.Binary Value { get; set; }
}
class WithPrivateConstructor
{
public int Foo { get; set; }
private WithPrivateConstructor() { }
}
public void TestWithNonPublicConstructor()
{
var output = connection.Query<WithPrivateConstructor>("select 1 as Foo").First();
output.Foo.IsEqualTo(1);
}
}
}
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