Bug 32966 - Type.GetType not working with anonymous types.
Summary: Type.GetType not working with anonymous types.
Alias: None
Product: Runtime
Classification: Mono
Component: Reflection ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-08-11 13:11 UTC by marcos.henrich
Modified: 2015-09-06 14:17 UTC (History)
2 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 marcos.henrich 2015-08-11 13:11:57 UTC
var x = new { a = 3 };
var ty = System.Type.GetType(x.GetType().AssemblyQualifiedName, true);

The code above throws the following exception:
System.TypeLoadException: Could not load type '<>__AnonType0`1[[System.Int32, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089]], eval-1, Version=, Culture=neutral, PublicKeyToken=null'.
  at (wrapper managed-to-native) System.Type:internal_from_name (string,bool,bool)
  at System.Type.GetType (System.String typeName, Boolean throwOnError) [0x00000] in <filename unknown>:0
  at <InteractiveExpressionClass>.Host (System.Object& $retval) [0x00000] in <filename unknown>:0
  at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object& result, System.Boolean& result_set) [0x00000] in <filename unknown>:0
  at Mono.CSharpShell.Evaluate (System.String input) [0x00000] in <filename unknown>:0
Comment 2 Marek Safar 2015-08-14 15:15:34 UTC
There is probably something else wrong. The test itself works in standalone app but the stack shows mscorlib as type owner which looks like.

Could  you extract better repro
Comment 3 marcos.henrich 2015-09-06 14:17:02 UTC
This happens because mcs names anonymous types differently than csc.

If mono class libraries were compiled with csc the test would no longer fail.

Marking this as a feature.