*****SPAM***** Re: [Mono-dev] typeof(Byte[]).GetInterfacesMap

Jonathan Pryor jonpryor at vt.edu
Sun May 21 11:24:01 EDT 2006


On Sun, 2006-05-21 at 06:40 -0500, Zac Bowling wrote:
> > (Sorry guys from before.. my spam filter has been sucking)

It's still sucking. :-)

> > returns:
> > 
> > Has 0 interfaces.
> > My interfaces:
> > BaseType's Interfaces:
> > Inheirts from System.Array+InternalArray`1[[System.Byte, mscorlib,
> > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
> > System.Collections.Generic.IList`1[[System.Byte, mscorlib,
> > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
> > System.Collections.Generic.ICollection`1[[System.Byte, mscorlib,
> > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
> > System.Collections.Generic.IEnumerable`1[[System.Byte, mscorlib,
> > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
> > System.Collections.IEnumerable
> > System.ICloneable
> > System.Collections.ICollection
> > System.Collections.IList

It's interesting because it's to be expected.  A `byte[]' is the actual
class type (otherwise `typeof (byte[])' wouldn't work), which has
System.Array as its base (in .NET 1.1).  Since System.Array actually
implements the interfaces, it makes sense that byte[] wouldn't, as it
can re-use the base class' version.

.NET 2.0 only modifies this slightly, due to the new class introduced
between byte[] and System.Array, System.Array.InternalArray.  This class
is necessary so that arrays can implement the generic interfaces --
byte[] implements ICollection<byte>, while System.Array does not -- but
the logic is otherwise the same: byte[] doesn't implement the
interfaces, its _base_ type does.

What really seems to have happened is that .NET 2.0's
System.Type.GetInterfaces() now returns all interfaces implemented by
the type and all its base types, as opposed to the .NET 1.1 version
which only returned interfaces implemented by the type itself.  (This is
only a guess based on the behavior I've seen, I haven't actually run any
tests to check this.)

 - Jon





More information about the Mono-devel-list mailing list