Open generic interface types of open implementation don't equal interface type?
Posted
by George Mauer
on Stack Overflow
See other posts from Stack Overflow
or by George Mauer
Published on 2010-04-20T20:19:38Z
Indexed on
2010/04/20
20:23 UTC
Read the original article
Hit count: 196
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).
© Stack Overflow or respective owner