Browse files

Fixed issue with FindBy delegates getting cached wrongly

  • Loading branch information...
1 parent 6004904 commit 97601fb55b28747b413dc42fbe7e440252bc39e2 @markrendle committed Sep 28, 2011
View
20 Simple.Data.Ado.Test/Simple.Data.Ado.Test.csproj
@@ -31,6 +31,15 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.mocks, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
+ </Reference>
+ <Reference Include="pnunit.framework, Version=1.0.4109.34242, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
@@ -39,17 +48,6 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
- <Reference Include="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.framework.dll</HintPath>
- </Reference>
- <Reference Include="nunit.mocks, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.mocks.dll</HintPath>
- </Reference>
- <Reference Include="pnunit.framework, Version=1.0.4000.25744, Culture=neutral, PublicKeyToken=null">
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\pnunit.framework.dll</HintPath>
- </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AdoAdapterExceptionTest.cs" />
View
2 Simple.Data.Ado.Test/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="NUnit" version="2.5.9.10348" />
+ <package id="NUnit" version="2.5.10.11092" />
</packages>
View
14 Simple.Data.BehaviourTest/Simple.Data.BehaviourTest.csproj
@@ -33,16 +33,14 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
- <Reference Include="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.framework.dll</HintPath>
+ <Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
</Reference>
- <Reference Include="nunit.mocks, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.mocks.dll</HintPath>
+ <Reference Include="nunit.mocks, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
</Reference>
- <Reference Include="pnunit.framework">
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\pnunit.framework.dll</HintPath>
+ <Reference Include="pnunit.framework, Version=1.0.4109.34242, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
View
2 Simple.Data.BehaviourTest/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="NUnit" version="2.5.9.10348" />
+ <package id="NUnit" version="2.5.10.11092" />
</packages>
View
14 Simple.Data.Mocking.Test/Simple.Data.Mocking.Test.csproj
@@ -33,16 +33,14 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
- <Reference Include="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.framework.dll</HintPath>
+ <Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
</Reference>
- <Reference Include="nunit.mocks, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.mocks.dll</HintPath>
+ <Reference Include="nunit.mocks, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
</Reference>
- <Reference Include="pnunit.framework">
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\pnunit.framework.dll</HintPath>
+ <Reference Include="pnunit.framework, Version=1.0.4109.34242, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
View
2 Simple.Data.Mocking.Test/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="NUnit" version="2.5.9.10348" />
+ <package id="NUnit" version="2.5.10.11092" />
</packages>
View
14 Simple.Data.SqlCe40Test/Simple.Data.SqlCe40Test.csproj
@@ -48,16 +48,14 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
- <Reference Include="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.framework.dll</HintPath>
+ <Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
</Reference>
- <Reference Include="nunit.mocks, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.mocks.dll</HintPath>
+ <Reference Include="nunit.mocks, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
</Reference>
- <Reference Include="pnunit.framework">
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\pnunit.framework.dll</HintPath>
+ <Reference Include="pnunit.framework, Version=1.0.4109.34242, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
View
2 Simple.Data.SqlCe40Test/packages.config
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
+ <package id="NUnit" version="2.5.10.11092" />
<package id="SqlServerCompact" version="4.0.8482.1" />
- <package id="NUnit" version="2.5.9.10348" />
</packages>
View
36 Simple.Data.SqlTest/OrderDetailTests.cs
@@ -22,5 +22,41 @@ public void TestOrderDetail()
Assert.IsNotNull(item);
Assert.AreEqual("Widget", item.Name);
}
+
+ [Test]
+ public void TestComplexObjectCreation()
+ {
+ var db = DatabaseHelper.Open();
+ var row = db.Customers.FindByCustomerId(1);
+ Customer customer = row;
+ customer.Orders.AddRange(row.Orders.Cast<Order>());
+
+ Assert.AreEqual("Test", customer.Name);
+ Assert.AreEqual(1, customer.Orders.Count);
+ Assert.AreEqual(1, customer.Orders.First().OrderId);
+ Assert.AreEqual(1, customer.Orders.First().CustomerId);
+ Assert.AreEqual(new DateTime(2010, 10, 10), customer.Orders.First().OrderDate);
+ }
+ }
+
+ class Customer
+ {
+ private readonly List<Order> _orders = new List<Order>();
+
+ public List<Order> Orders
+ {
+ get { return _orders; }
+ }
+
+ public int CustomerId { get; set; }
+ public string Name { get; set; }
+ public string Address { get; set; }
+ }
+
+ class Order
+ {
+ public int OrderId { get; set; }
+ public DateTime OrderDate { get; set; }
+ public int CustomerId { get; set; }
}
}
View
14 Simple.Data.SqlTest/Simple.Data.SqlTest.csproj
@@ -33,16 +33,14 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
- <Reference Include="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.framework.dll</HintPath>
+ <Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
</Reference>
- <Reference Include="nunit.mocks, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.mocks.dll</HintPath>
+ <Reference Include="nunit.mocks, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
</Reference>
- <Reference Include="pnunit.framework">
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\pnunit.framework.dll</HintPath>
+ <Reference Include="pnunit.framework, Version=1.0.4109.34242, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
View
2 Simple.Data.SqlTest/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="NUnit" version="2.5.9.10348" />
+ <package id="NUnit" version="2.5.10.11092" />
</packages>
View
14 Simple.Data.TestHelper/Simple.Data.TestHelper.csproj
@@ -31,16 +31,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.framework.dll</HintPath>
+ <Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
</Reference>
- <Reference Include="nunit.mocks, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.mocks.dll</HintPath>
+ <Reference Include="nunit.mocks, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
</Reference>
- <Reference Include="pnunit.framework">
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\pnunit.framework.dll</HintPath>
+ <Reference Include="pnunit.framework, Version=1.0.4109.34242, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
View
1 Simple.Data.TestHelper/packages.config
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.5.9.10348" />
+ <package id="NUnit" version="2.5.10.11092" />
</packages>
View
14 Simple.Data.UnitTest/Simple.Data.UnitTest.csproj
@@ -33,16 +33,14 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
- <Reference Include="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.framework.dll</HintPath>
+ <Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
</Reference>
- <Reference Include="nunit.mocks, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\nunit.mocks.dll</HintPath>
+ <Reference Include="nunit.mocks, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
</Reference>
- <Reference Include="pnunit.framework">
- <HintPath>..\packages\NUnit.2.5.9.10348\lib\pnunit.framework.dll</HintPath>
+ <Reference Include="pnunit.framework, Version=1.0.4109.34242, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
View
2 Simple.Data.UnitTest/packages.config
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="NUnit" version="2.5.9.10348" />
+ <package id="NUnit" version="2.5.10.11092" />
<package id="Trespasser" version="1.1" />
</packages>
View
8 Simple.Data/DynamicTable.cs
@@ -55,7 +55,7 @@ internal DynamicTable(string tableName, DataStrategy dataStrategy, DynamicSchema
/// </returns>
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
{
- var func = _delegates.GetOrAdd(binder.Name, name => CreateMemberDelegate(name,binder,args));
+ var func = _delegates.GetOrAdd(CreateDelegateName(binder), name => CreateMemberDelegate(name, binder, args));
if (func != null)
{
result = func(args);
@@ -72,6 +72,12 @@ public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, o
return base.TryInvokeMember(binder, args, out result);
}
+ private static string CreateDelegateName(InvokeMemberBinder binder)
+ {
+ // Construct the name from the method name and any named arguments, so that "FindBy(Id:1)" and "FindBy(Age:42)" have separate delegates.
+ return binder.Name + " " + string.Join(" ", binder.CallInfo.ArgumentNames);
+ }
+
private Func<object[],object> CreateMemberDelegate(string name, InvokeMemberBinder binder, object[] args)
{
try

0 comments on commit 97601fb

Please sign in to comment.