Hi

It seems that there is a interpretation bug in the
CustomAttributeBuilder.get_umarshal method.

Some fix for the CustomAttributeBuilder.cs file is included with this post.
(I don't know where to find the meaning of the two bytes before string
size). If I trust the header of the file, this is your code Paolo.

But this does not seem to be enough, for the type description of this struct
:

    [StructLayout(LayoutKind.Sequential)]
    public struct Test {
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst=4)]
        public string a;
    }

Here is the IL disassembly from the mcs generated file :

    .field public marshal( fixed sysstring []) string a

Whereas with the csc generated file it is :

    .field public marshal( fixed sysstring[4]) string a

This seems to be an IL emitter bug, but I cannot find where it is...

By the way, the test file marshal2.cs fails with mono 0.19 and probably with
the 0.18 too.

___________
Jerome.

----- Original Message ----- 
From: "J�r�me LABAN" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 25, 2003 9:08 PM
Subject: Re: [Mono-list] Marshaling problem in .19


> I'm also having troubles using String marshalling in some cases :
>
>     [MarshalAs(UnmanagedType.ByValStr, SizeConst=16)]
>
> seems to be loaded as
>
>     [MarshalAs(UnmanagedType.LPStr)]
>
> While actually, in the method emit_struct_info (marshal.c) on the line
3013,
> I presume that
> the info->fields[i].mspec should not return a NULL pointer when a marshal
> attribute is set.
>
> Using LPStr while it should be ByValStr leads the marshaller to use string
> data as a pointer.
>
> Is this a type loader problem ? mspec member should be filled with
something
> I guess...
>

Attachment: CustomAttributeBuilder.cs.diff
Description: Binary data

Reply via email to