Trying to mock interface with extented method constraint.

80 views
Skip to first unread message

Mads

unread,
Jul 30, 2007, 3:21:46 AM7/30/07
to Rhino.Mocks
Hi A,

First of all, thank you for a great mock framework.

I think the best way to descripe my problem is with an example:

[TestMethod]
public void TestMethodTest()
{
var mocks = new MockRepository();

var mockedInterface =
mocks.CreateMock<TestInterface<List<string>>>();

}

public interface TestInterface<T> where T :
IEnumerable<string>
{
string TestMethod<T2>(T2 obj) where T2 : T,
ICollection<string>;
}

Then the following error is thrown every time:

System.TypeLoadException: Method 'TestMethod' on type
'TestInterface`1Proxyce0a676c66b44b9f8632d97eb36a32c8' from assembly
'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=a621a9e7e5c32e69' tried to implicitly implement an
interface method with weaker type parameter constraints..

Is there any way to get around with this?

Thank you,

Mads

Ayende Rahien

unread,
Jul 30, 2007, 4:27:24 AM7/30/07
to Rhino...@googlegroups.com
No, this is a bug in Rhino Mocks' subclass generation, I'll get to fixing it soon, I hope.

Ayende Rahien

unread,
Aug 13, 2007, 12:17:53 PM8/13/07
to Rhino...@googlegroups.com
Mads, I really hate to do this, but I am going to resolve this as won't fix.
The underlying issue is a framework bug that we cannot work around.
Reply all
Reply to author
Forward
0 new messages