Bug 57938 - Differences in behavior Type.Fullname in Mono and .NET Framework when Type is a generic type that is not a generic type definition but contains unresolved type parameters
Summary: Differences in behavior Type.Fullname in Mono and .NET Framework when Type is...
Status: CONFIRMED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib (show other bugs)
Version: master
Hardware: PC All
: --- normal
Target Milestone: Future Release
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-07-05 11:07 UTC by Dmitriy
Modified: 2017-09-11 17:52 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Dmitriy 2017-07-05 11:07:59 UTC
I have an issue with one Inversion of Control container product. It crashed on mono. Investigation showed that the reason is in behavior of Type.Fullname property.

A little example code:

    public class SomeContract
    {
        public string Data { get; set; }
    }

    public interface IExample<T1> where T1 : SomeContract{}

    public class ExampleImpl<T1> : IExample<T1>
        where T1 : SomeContract{}

    class Program
    {
        static void Main(string[] args)
        {
            var t = typeof(ExampleImpl<>);
            var ifaces = t.GetTypeInfo().ImplementedInterfaces;
            foreach (var iface in ifaces)
            {
                var fullname = iface.FullName == null ? "NULL" : iface.FullName;
                Console.WriteLine($"Name: {iface.Name}");
                Console.WriteLine($"FullName :{fullname}");
                Console.WriteLine($"IsGenericParameter: {iface.IsGenericParameter}");
                Console.WriteLine($"IsGenericType: {iface.IsGenericType}");
                Console.WriteLine($"IsGenericTypeDefinition: {iface.IsGenericTypeDefinition}");
                Console.WriteLine($"ContainsGenericParameters: {iface.ContainsGenericParameters}");

            }
            Console.ReadLine();
        }
    }
The output on .Net Framework 4.5.2 :
Name: IExample`1
FullName :NULL  <-------
IsGenericParameter: False
IsGenericType: True
IsGenericTypeDefinition: False
ContainsGenericParameters: True

The output on Mono 5.0.1:
Name: IExample`1
FullName :IsGenericTypeDefinition.IExample`1[T1]  <------
IsGenericParameter: False
IsGenericType: True
IsGenericTypeDefinition: False
ContainsGenericParameters: True

According to microsoft documentation :
The fully qualified name of the type, including its namespace but not its assembly; or null if the current instance represents a generic type parameter, an array type, pointer type, or byref type based on a type parameter, or a generic type that is not a generic type definition but contains unresolved type parameters.

https://docs.microsoft.com/en-us/dotnet/api/system.type.fullname?view=netframework-4.5#System_Type_FullName    

This issue was reproduced on Windows 10 and Linux distr based on Debian 7.
Comment 1 Marek Safar 2017-09-11 17:52:44 UTC
Mono master output

Name: IExample`1
FullName :IExample`1[T1]
IsGenericParameter: False
IsGenericType: True
IsGenericTypeDefinition: False
ContainsGenericParameters: True

Note You need to log in before you can comment on or make changes to this bug.