Open generic interface types of open implementation don't equal interface type?
- by George Mauer
Here's a test that should, in my opinion be passing but is not.
[TestMethod]
public void can_get_open_generic_interface_off_of_implementor()
{
typeof(OpenGenericWithOpenService<>).GetInterfaces().First()
.ShouldEqual(typeof(IGenericService<>));
}
public interface IGenericService<T> { }
public class OpenGenericWithOpenService<T> : IGenericService<T> { }
Why does this not pass?
Given Type t = typeof(OpenGenericWithOpenService<>) how do I get typeof(IGenericService<)?
I'm generally curious, but if you're wondering what I'm doing, I'm writing a Structuremap convention that forwards all interfaces implemented by a class to the implementation (as a singleton).