Bug 17747 - PCL System.Type.GetNestedTypes() missing
Summary: PCL System.Type.GetNestedTypes() missing
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.13.x
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2014-02-13 08:25 UTC by BurnSpamAddress
Modified: 2014-04-16 12:26 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 Developer Community or GitHub 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 BurnSpamAddress 2014-02-13 08:25:43 UTC
According to MSDN[1], System.Type.GetNestedTypes(BindingFlags) is supported on Portable Class Library projects.

However, I am getting an error when trying to use this method on a Xamarin Studio PCL project: "Error CS1061: Type `System.Type' does not contain a definition for `GetNestedTypes' and no extension method `GetNestedTypes' of type `System.Type' could be found. Are you missing an assembly reference? (CS1061)"

I am using the following Project Options:

Current Profile:
4.5 - Profile78

Target Frameworks:
.NET Framework 4.5 or later
Windows Phone 8
Windows Store apps (Windows 8)

Any idea how to make this work?
Comment 1 narayanp 2014-02-13 10:10:13 UTC
I have checked this issue with following build:

All Windows
X.S 4.2.4(build 17)
Mono 3.2.7
X.Android 4.12.0-22

I am also not seeing System.Type.GetNestedTypes. However this is present in Visual Studio.
Comment 2 Jonathan Pryor 2014-04-16 11:46:44 UTC
> According to MSDN[1], System.Type.GetNestedTypes(BindingFlags) is supported on
> Portable Class Library projects.

You seem to be missing [1]; presumably, it's: http://msdn.microsoft.com/en-us/library/493t6h7t(v=vs.110).aspx

The problem is that "Supported in: Portable Class Library" is nearly meaningless: it means it's supported in _some_ PCL profiles, but not necessarily all, and the documentation doesn't say in which profile the member is available in.

Which is where `grep` comes in:

$ cd /Library/Frameworks/Mono.framework/Libraries/mono/xbuild-frameworks/.NETPortable
$ grep -rl GetNestedTypes .

From the above, we can see that GetNestedTypes() is available in profiles 5, 6, 14, 19, 24, 37, 42, 47, 136, 147, and 158.

Note that profile 78 is not in that list, at least for the PCL profile assemblies that Mono 3.2.6 includes on OS X.
Comment 3 Martin Baulig 2014-04-16 12:22:25 UTC
You want System.Reflection.TypeInfo.GetDeclaredNestedTypes().

In PCL v4.5, the "traditional" reflection APIs have been replaced by new ones in System.Reflection.  There's a new TypeInfo, MethodInfo, etc. in there.
Comment 4 Martin Baulig 2014-04-16 12:26:15 UTC
Here's a good article which explains these new APIs: