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

Jb Evain mono at evain.net
Mon May 8 08:14:29 EDT 2006


Hey,

I was just having a look at that :)

On May 8, 2006, at 1:50 PM, Jonathan Pryor wrote:
> The above test prints out _nothing_.  This is because System.Byte[]
> doesn't implement any interfaces, rather it's System.Byte[]'s _base_
> type which implements all the interfaces, and Mono's
> Type.GetInterfaces() method doesn't return the interfaces  
> implemented by
> the base type, but just the interfaces implemented by the specified
> type.
>
> Perhaps this is a bug (I don't have a .NET runtime to test against),
> though it makes sense to me.

In .net 1.0, typeof (an_array).GetInterfaces () was returning an  
empty array.
In .net 2.0, it is returning an array of interfaces implemented by  
the array's element type.

It could be fix by something like:

Index: icall.c
===================================================================
--- icall.c	(revision 59720)
+++ icall.c	(working copy)
@@ -1676,8 +1676,8 @@
	slots = mono_bitset_new (class->max_interface_id + 1, 0);
-	if (class->rank) {
-		/* GetInterfaces() returns an empty array in MS.NET (this may be a  
bug) */
+	if (mono_defaults.corlib->assembly->aname.major < 2 && class->rank) {
+		/* GetInterfaces() returns an empty array in MS.NET 1 */
		mono_bitset_free (slots);
		return mono_array_new (domain, mono_defaults.monotype_class, 0);
	}


Thought, I don't like this patch very much.

Jb




More information about the Mono-devel-list mailing list