Commit c873a24d authored by Marc Gravell's avatar Marc Gravell

FIX: work with non-public constructors

parent aec04802
...@@ -1331,7 +1331,7 @@ static List<FieldInfo> GetSettableFields(Type t) ...@@ -1331,7 +1331,7 @@ static List<FieldInfo> GetSettableFields(Type t)
il.BeginExceptionBlock(); il.BeginExceptionBlock();
// stack is empty // 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; bool first = true;
var allDone = il.DefineLabel(); var allDone = il.DefineLabel();
foreach (var item in setters) foreach (var item in setters)
......
...@@ -1038,6 +1038,18 @@ class WithBinary ...@@ -1038,6 +1038,18 @@ class WithBinary
{ {
public System.Data.Linq.Binary Value { get; set; } 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