Bug 26412 - ConstructorInfo.ContainsGenericParameters behaves differently to MS.NET
Summary: ConstructorInfo.ContainsGenericParameters behaves differently to MS.NET
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
Depends on:
Reported: 2015-01-26 06:51 UTC by Alexander Jesner
Modified: 2015-01-26 12:15 UTC (History)
3 users (show)

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:

Description Alexander Jesner 2015-01-26 06:51:20 UTC
ConstructorInfo.ContainsGenericParameters seems to behave differently to MS.NET
  on Windows is is true for types with generic type parameters 
  on Linux it is false for the same generic type.

This code snippet can be used to reproduce the error:

using System;

public class Test
  class Something<T>        
  { }

  public static void Main()
      var type = typeof(Something<>);
      Console.WriteLine("{0}.ContainsGenericParameters: {1}", type.Name, type.ContainsGenericParameters);

      var ctor = type.GetConstructor(new Type[0]);
      Console.WriteLine("{0}.ContainsGenericParameters: {1}", ctor.Name, ctor.ContainsGenericParameters);

I tested with two different Mono versions and .NET 4.5:

Output on Windows (.NET 4.5.51209)
    Something`1.ContainsGenericParameters: True
    .ctor.ContainsGenericParameters: True

Output on Linux (Mono JIT compiler version 3.6.0 ((detached/f2987d2 Thu Oct  9 09:28:22 CEST 2014)
    Something`1.ContainsGenericParameters: True
    .ctor.ContainsGenericParameters: False

Output on Linux (Mono JIT compiler version 3.12.0 (tarball Sun Jan 25 23:32:43 PST 2015)
    Something`1.ContainsGenericParameters: True
    .ctor.ContainsGenericParameters: False
Comment 1 Alexander Jesner 2015-01-26 07:33:00 UTC
Update: It seems that older MS.NET versions (2.0, 3.5) show the same behaviour as Mono. The reported bug is only true when targeting assemblies for >= 4.0.
Comment 2 Marek Safar 2015-01-26 12:15:51 UTC
Fixed in master