Reflection API Changes For Windows Store Apps
.NET API subset for Windows Store Apps is considerable smaller than the full .NET Framework 4.5. Particularly, Reflection.Emit is not available and most members in the System.Type class have been moved to the System.Reflection.TypeInfo class.
The .NET Team has split System.Type into two classes – System.Reflection.TypeInfo and a reduced System.Type – to mainly separate the concerns of type definitions and type references. This kind of separation already existed when dealing with Assemblies. Brandon Bray explains in the article Evolving the .NET Reflection API -
The System.Reflection.Assembly class represents assembly definitions, whereas the System.Reflection.AssemblyName class represents assembly references. The former exposes rich functionality, and the latter is just data that helps you get the definition should you want it. That’s exactly the model that we wanted to adopt for System.Type.
The Type will only provide a reference to a Type and does not load all the metadata about the type itself. All the rich information of a Type is now within TypeInfo – given a Type you can get the TypeInfo of that type for accessing the metadata. The advantage of this, is that accessing the Type object does not require loading the necessary assembly – that is needed only when accessing the TypeInfo class. This means the control of whether loading an assembly is needed is now with the developer depending on what she wants to achieve.
The Reflection API also starts using IEnumerable instead of Arrays as the return type for most of the methods for better working set and responsiveness.
Compatibility: The new Reflection API is not a breaking change – using the new model is mandatory for Windows Store Apps, but for code targeting .NET Framework 4.5, you can use both the earlier (.NET 4.0 model) or the new model for Reflection. To achieve this, the .NET Framework types use a slightly different type hierarchy. In case you intend to reuse your reflection code between .NET 4.5 and Windows Store apps, Microsoft recommends that you package that as a Portable Class Library.
Shane Hastie Aug 23, 2014
Srini Penchikala Aug 21, 2014