Rhino Mocks 2.0.6
Okay, this release is actually an interesting one. The problem it solves is running Rhino Mocks on the .Net 2.0 Framework.
Somewhere deep in the bowels of Rhino Mocks, there is a method that return a default value for method that are called during the recording phase, it looks like this:
public
static object DefaultValue(Type type){
if (type.IsValueType == false)
return null;
return Activator.CreateInstance(type);
}
The problem was what would happen when you get a void type [ typeof(void) ]. On .Net 1.0 and 1.1 this just worked, and you actually got a System.Void instance that you could play with. On .Net 2.0, you get a not supported exception, which seems reasonable, except that it breaks my code and that is not reasonable :-)
Anyway, on a hunch, I modify the code to do this:
public static object DefaultValue(Type type)
{
if (type.IsValueType == false || type==typeof(void))
return null;
return Activator.CreateInstance(type);
}
And now it's working. And no, methods with void return type won't start to return nulls all over the place. Dyamic Proxy handles it, acutally. It simply discard any return value from the interceptor for a method with a void return value, so everything is happy again.
I'm currently installing .Net 2.0 and I'll give Rhino Mocks a twirl using C# 2.0, and see if all the tests pass on it. What do you think should change to accomodate 2.0 beyond the obvious:
Comments
Comment preview