[Mono-dev] Why is UnmanagedType_80 required?

Kornél Pál kornelpal at hotmail.com
Wed Aug 31 06:31:11 EDT 2005


>>>>>> According to my experiences using no ArraySubType has the same result
>>>>>> as
>>>>>> ArraySubType = (UnmanagedType)80 on mcs and csc.exe as well.
>>>>>>
>>>>>> Could someone tell me please why UnmanagedType_80 is required?
>>>>>
>>>>>There was a bug in ancient versions of mcs wrt. constant folding in
>>>>>attribute arguments.  We needed to declare an explicit enumeration
>>>>>constant, and use that instead.
>>>>
>>>> I think in this case we could simply eliminate UnmanagedType_80 in
>>>> favour of
>>>> using no ArraySubType as I think we support those ancient versions no
>>>> more.
>>>>
>>>>>The actual reason for using '(UnmanagetType) 80': probably corcompare.
>>>>
>>>> Using no ArraySubType and using ArraySubType = (UnmanagedType)80
>>>> results in
>>>> the same binary file.
>>>
>>> I don't think so.  It will be emitted in the MarshalAsAttribute
>>> metadata.
>>
>> Hmm...  I spoke too soon.  It's a pseudo-attribute.  With no
>> ArraySubType specified, the current mcs compiler code seems to set the
>> element type of the LParray marshaller to 'int' (I4).  ArraySubType set
>> to '80' i.e. MAX, specifies to the marshaller that there's "no info"
>> about the element type.
>>
>> Either way, I think there should be a difference in the metadata.
>
>(Sorry for following up to myself so much :-)
>
>It turns out that this behaviour could be a bug in our compiler.  CSC
>and Mono's SRE appear to behave as you say -- not specifying
>ArraySubType acts the same as specifying (UnmanagedType)80.

I found another difference in ildasm output when using SizeParamIndex as
well. So I'm going to file a bug report with some examples.

When mcs will emit correct metadata when using no ArraySubType can
(UnmanagedType)80 be removed and use no ArraySubType without problems?

Kornél




More information about the Mono-devel-list mailing list