Previously, I mentioned some things in Metadata that aren't exposed in Reflection. Here's an opposite case.
While metadata represents static bits on disk, Reflection operates in a live process with access to the CLR's loader. So reflection can represent things the CLR loader and type system may do that aren't captured in the metadata.
For example, an array T[] may implement interfaces, but which set of interfaces is not captured in the metadata. So consider the following code that prints out the interfaces an int[] implements:
using System; class Foo { static void Main() { Console.WriteLine("Hi"); Console.WriteLine(Environment.Version); Type[] t2 = typeof(int[]).GetInterfaces(); foreach (Type t in t2) { Console.WriteLine(t.FullName); } Console.WriteLine("done"); } }
Compile it once for v1.0. Then run the same binary against v1 and v2. It's the same file (and therefore same metadata) in both cases.
The V1 case is inconsistent because it doesn't show any interfaces, it should at least show a few builtins like IEnumerable (typeof(IEnumerable).IsAssignableFrom(typeof(int[])) == True). But in the v2 case, you see reflection showing the interfaces, particularly the new 2.0 generic interfaces, that the CLR's type system added to the the array. So the V2 list is not the same as the V1 list, but this difference is not captured in the metadata.
C:\temp>c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\csc.exe t.cs Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4 for Microsoft (R) .NET Framework version 1.1.4322 Copyright (C) Microsoft Corporation 2001-2002. All rights reserved. C:\temp>t.exe Hi 1.1.4322.2407 done C:\temp>set COMPLUS_VERSION=v2.0.50727 C:\temp>t.exe Hi 2.0.50727.1433 System.ICloneable System.Collections.IList System.Collections.ICollection System.Collections.IEnumerable System.Collections.Generic.IList`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] System.Collections.Generic.ICollection`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] System.Collections.Generic.IEnumerable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] done |