Bug 26342 - Type.GetType returns null instead of a Dictionary
Summary: Type.GetType returns null instead of a Dictionary
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: Reflection ()
Version: unspecified
Hardware: PC All
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-01-23 09:24 UTC by guillaume.turri
Modified: 2015-01-25 03:09 UTC (History)
2 users (show)

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


Attachments
Test case. Gives null type on Mono, whereas the expected type on .net (369 bytes, text/x-csharp)
2015-01-24 04:20 UTC, guillaume.turri
Details


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 guillaume.turri 2015-01-23 09:24:48 UTC
Hi,

The following snippet doesn't behave the same with .Net and with Mono:

    string strType = "System.Collections.Generic.Dictionary`2[[System.Int32,mscorlib], [System.String,mscorlib]],mscorlib";
    var type = Type.GetType(strType);
    
    if (type != null)
    {
        Console.WriteLine(type);
    }
    else
    {
        Console.WriteLine("Type is null");
    }


* Expected (behavior obtained with .Net): type isn't null, and it prints "System.Collections.Generic.Dictionary`2[System.Int32,System.String]"

* Actual: type is null

I just tested it with a version of Mono build from master (a09f7fc6)
Comment 1 Zoltan Varga 2015-01-23 20:19:40 UTC
Can't reproduce this, neither with 3.12, nor with mono master using the following testcase:

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
using System;

public class Tests
{
	public static void Main (String[] args) {
		string strType =
			"System.Collections.Generic.Dictionary`2[[System.Int32,mscorlib],[System.String,mscorlib]],mscorlib";
    var type = Type.GetType(strType);

    if (type != null)
    {
        Console.WriteLine(type);
    }
    else
    {
        Console.WriteLine("Type is null");
    }
	}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Comment 2 guillaume.turri 2015-01-24 04:20:39 UTC
Created attachment 9483 [details]
Test case. Gives null type on Mono, whereas the expected type on .net
Comment 3 guillaume.turri 2015-01-24 04:21:17 UTC
Sorry, because of the inserted line break, my snippet is ambiguous. Actually you should add a whitespace after the comma, as in

    [System.Int32,mscorlib], [System.String,mscorlib]

I just attached my test case to make it easier to reproduce
Comment 4 Zoltan Varga 2015-01-24 19:23:57 UTC
Fixed in mono master b21fe11d6c18c8d0dc26f8959f439ebc354be9bf.
Comment 5 guillaume.turri 2015-01-25 03:09:40 UTC
That was fast!
Thanks!