I thought GetInterfaceMap should work for every interface returned by
GetInterfaces()... but here I have a counterexample. Has anyone seen this
before? Here's a unit test for Zanebug (substitute your favorite test
runner):
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));
}
}
}
It fails for GetInterfaces()[4/5/6], which are the instantiated generic
interfaces, IList<Byte>, ICollection<Byte>, and IEnumerable<Byte>. Is this
a bug, or is it documented somewhere that it should work this way?
------ 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.
Ben Voigt - 12 May 2006 18:02 GMT
Ok, got my MSDN subscription again, so posting with this account I should
get a response?
BTW, I asked the mono developers and it works fine with gmcs. Only .NET has
this problem.
>I thought GetInterfaceMap should work for every interface returned by
>GetInterfaces()... but here I have a counterexample. Has anyone seen this
[quoted text clipped - 41 lines]
>
> 0 passed, 1 failed, 0 skipped, took 1.39 seconds.