mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-28 04:29:51 +08:00
FIX: work with non-public constructors
This commit is contained in:
+1
-1
@@ -1331,7 +1331,7 @@ IDataReader reader, int startBound = 0, int length = -1, bool returnNullIfFirstM
|
||||
|
||||
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)
|
||||
|
||||
+13
-1
@@ -1038,6 +1038,18 @@ Order by p.Id";
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user