GetInterfaces () returns a generic interface type with FullName = null

Can someone explain to me why GetInterfaces () in the code below returns an interface type that has FullName = null?

public class Program
{
    static void Main(string[] args)
    {
        Type[] interfaces = typeof (Data<>).GetInterfaces();
        foreach (Type @interface in interfaces)
        {
            Console.WriteLine("Name='{0}' FullName='{1}'", @interface.Name, @interface.FullName ?? "null");
        }
    }
}

public class Data<T> : IData<T>
{
    public T Content { get; set; }
}

public interface IData<T>
{
    T Content { get; set; }
}

Program Output:

Name=IData`1' FullName='null'

I expect:

Name=IData`1'
FullName='ConsoleApplication2.IData`1'

Please enlighten me :)

+2
source share
1 answer

http://blogs.msdn.com/b/haibo_luo/archive/2006/02/17/534480.aspx

Update: improved Microsoft documentation:

https://msdn.microsoft.com/en-us/library/system.type.fullname.aspx

Type.FullName null, , , byref , , .

, Type.FullName null, :

    [Fact]
    public void FullNameOfUnresolvedGenericArgumentIsNull()
    {
        Type openGenericType = typeof(Nullable<>);
        Type typeOfUnresolvedGenericArgument = openGenericType.GetGenericArguments()[0];

        Assert.Null(typeOfUnresolvedGenericArgument.FullName);
    }
+7

Source: https://habr.com/ru/post/1617053/


All Articles