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: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib (show other bugs)
Version: master
Hardware: PC All
: --- normal
Target Milestone: Future Release
Assignee: Katelyn Gadd
URL:
Depends on:
Blocks:
 
Reported: 2017-07-05 11:07 UTC by Dmitriy
Modified: 2017-11-08 07:06 UTC (History)
3 users (show)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

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
Comment 2 Katelyn Gadd 2017-11-08 07:06:36 UTC
Fixed by https://github.com/mono/mono/pull/5920