[Mono-dev] typeof(Byte[]).GetInterfacesMap

Zac Bowling zac at zacbowling.com
Sun May 21 08:57:48 EDT 2006


(Sorry guys from before.. my spam filter has been sucking)

Ok.. Maybe this explains it:

This test app:
---
using System;
namespace TestApp
{
    class Program
    {


        public static void Main (string[] args)
        {

            System.Type baseType = typeof(Byte[]);

            Console.WriteLine("Has {0} interfaces.",
baseType.GetInterfaces().Length);
            Console.WriteLine("Inheirts from {0}",
baseType.BaseType.FullName);
            Console.WriteLine("My interfaces:");
            foreach (System.Type iface in baseType.GetInterfaces())
            {
                Console.WriteLine(iface.FullName);
            }
            Console.WriteLine("BaseType's Interfaces:");
            foreach (System.Type iface in baseType.BaseType.GetInterfaces())
            {
                Console.WriteLine(iface.FullName);
            }
        }
    }
}
---

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

still might be a bug there but that's pretty interesting :-)

----
Zac Bowling <zac at zacbowling.com>
http://zacbowling.com/


Voigt, Benjamin wrote:
> Would someone please be so kind as to run the following unit test on Mono?  It's written against Zanebug but should be easy to run with any testing framework.
>
> using Adapdev.UnitTest;
>
> [TestFixture]
> class GetInterfaceMap
> {
>     [Test]
>     public static void ByteArray()
>     {
>         System.Type baseType = typeof(System.Byte[]);
>         foreach (System.Type iface in baseType.GetInterfaces())
>         {
>             System.Diagnostics.Trace.WriteLine(iface.FullName);
>             Assert.IsNotNull(baseType.GetInterfaceMap(iface));
>         }
>     }
> }
>
> If it fails on Mono, can someone explain why?  If it succeeds, I'm off to tell Microsoft their .NET 2.0 runtime isn't worth the hard disk space to hold it....
>
> I'm asking because Microsoft fails miserably for GetInterfaces()[4/5/6] which are IList<Byte>, ICollection<Byte>, and IEnumerable<Byte>:
>
> ------ Test started: Assembly: RealTime.Tests.dll ------
>
> System.ICloneable
> System.Collections.IList
> System.Collections.ICollection
> System.Collections.IEnumerable
> System.Collections.Generic.IList`1[[System.Byte, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
> TestCase 'M:GetInterfaceMap.ByteArray' failed: Interface not found.
> 	System.ArgumentException: Interface not found.
> 	at System.RuntimeTypeHandle.GetFirstSlotForInterface(IntPtr interfaceHandle)
> 	at System.RuntimeTypeHandle.GetFirstSlotForInterface(RuntimeTypeHandle interfaceHandle)
> 	at System.RuntimeType.GetInterfaceMap(Type ifaceType)
> 	Realtime\RealTimeTests\GetInterfaceMap.cs(13,0): at GetInterfaceMap.ByteArray()
>
>
> 0 passed, 1 failed, 0 skipped, took 1.39 seconds.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>   







More information about the Mono-devel-list mailing list