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

Jb Evain mono at evain.net
Tue May 9 10:20:05 EDT 2006


Hello,

Here is a solution I like most.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mcs.patch
Type: application/octet-stream
Size: 801 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060509/49e444d6/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mono.diff
Type: application/octet-stream
Size: 1338 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060509/49e444d6/attachment-0001.obj 
-------------- next part --------------

Comments?

Jb

On May 8, 2006, at 2:14 PM, Jb Evain wrote:

> 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
>
> _______________________________________________
> 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