When reflecting on an interface type, I only get the members of the specific type, not inherited members.
In this over-simplified example, the program only prints "Name", not "ItemNumber", "Name" as I would expect:
using System;
public interface IBasicItem
{
string ItemNumber { get; set; }
}
public interface IItem : IBasicItem
{
string Name { get; set; }
}
class Program
{
static void Main(string[] args)
{
var type = typeof (IItem);
foreach (var prop in type.GetProperties())
Console.WriteLine(prop.Name);
}
}
What is the rationale behind this ? When I am inheriting from the base interface, I am saying that any of the implementations of my interface, must also implement the inherited members. In other words, IItem is-a IBasicItem. So why does the inherited member not show up using reflection ?