[Mono-list] Patches for MarshalAsAttribute in 0.19

Jerome Laban jlaban@wanadoo.fr
Mon, 27 Jan 2003 00:19:48 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_05CF_01C2C599.CDCB0DE0
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_05D0_01C2C599.CDD2AF00"


------=_NextPart_001_05D0_01C2C599.CDD2AF00
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

Thanks to miguel I've found where the problem concerning the =
MarshalAsAttribute was. The blob containing the pseudo custom attribute =
data was not filled at all when using mcs to generate the assembly.

So, here are tree patches for Mono-0.19, maybe partial but fixing the =
marshaling for types UnmanagedType.ByValArray and =
UnmanagedType.ByValTStr with a SizeConst parameter.

mono-0.19/mono/metadata/reflection.c
mcs-0.19/class/System.Reflection.Emit/FieldBuilder.cs
mcs-0.19/class/System.Reflection.Emit/CustomAttributeBuilder.cs

(Sorry if patches are not like they are used to be, I'm not used to make =
diff files)

These patches allows marshal1 to marshal4 tests to run without errors.

Could anyone test it and commit it if ok ?

thanks,

Jerome.
------=_NextPart_001_05D0_01C2C599.CDD2AF00
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1126" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Thanks to miguel I've found where the problem =
concerning the=20
MarshalAsAttribute was. The blob containing the pseudo custom attribute =
data was=20
not filled at all when using mcs to generate the assembly.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>So, here are tree patches for Mono-0.19, maybe =
partial but=20
fixing the marshaling for types UnmanagedType.ByValArray and=20
UnmanagedType.ByValTStr with a SizeConst parameter.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>mono-0.19/mono/metadata/reflection.c</FONT></DIV>
<DIV><FONT=20
size=3D2>mcs-0.19/class/System.Reflection.Emit/FieldBuilder.cs</FONT></DI=
V>
<DIV><FONT=20
size=3D2>mcs-0.19/class/System.Reflection.Emit/CustomAttributeBuilder.cs<=
/FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>(Sorry if patches are not like they are used to be, =
I'm not=20
used to make diff files)</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>These patches allows marshal1 to marshal4 tests to =
run without=20
errors.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Could anyone test it and commit it if ok =
?</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>thanks,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Jerome.</FONT></DIV></BODY></HTML>

------=_NextPart_001_05D0_01C2C599.CDD2AF00--

------=_NextPart_000_05CF_01C2C599.CDCB0DE0
Content-Type: application/octet-stream;
	name="reflection.c.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="reflection.c.diff"

1057,1060c1057,1066=0A=
< 	/* FIXME: handle ARRAY and other unmanaged types that need extra info =
*/=0A=
< 	default:=0A=
< 		mono_metadata_encode_value (minfo->type, p, &p);=0A=
< 		break;=0A=
---=0A=
>         case MONO_NATIVE_BYVALTSTR:=0A=
>         case MONO_NATIVE_BYVALARRAY:=0A=
>             mono_metadata_encode_value (minfo->type, p, &p);=0A=
>             mono_metadata_encode_value (minfo->count, p, &p);=0A=
>             break;=0A=
> =0A=
> 	    /* FIXME: handle ARRAY and other unmanaged types that need extra =
info */=0A=
> 	    default:=0A=
> 		    mono_metadata_encode_value (minfo->type, p, &p);=0A=
> 		    break;=0A=

------=_NextPart_000_05CF_01C2C599.CDCB0DE0
Content-Type: application/octet-stream;
	name="FieldBuilder.cs.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="FieldBuilder.cs.diff"

96a97=0A=
>                 attrs |=3D FieldAttributes.HasFieldMarshal;=0A=

------=_NextPart_000_05CF_01C2C599.CDCB0DE0
Content-Type: application/octet-stream;
	name="CustomAttributeBuilder.cs.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="CustomAttributeBuilder.cs.diff"

69,74c69,71=0A=
< 		internal static string string_from_bytes (byte[] data, int pos, int =
len) {=0A=
< 			char[] chars =3D new char [len];=0A=
< 			// FIXME: use a utf8 decoder here=0A=
< 			for (int i =3D 0; i < len; ++i)=0A=
< 				chars [i] =3D (char)data [pos + i];=0A=
< 			return new String (chars);=0A=
---=0A=
>         internal static string string_from_bytes (byte[] data, int =
pos, int len)=20
>         {=0A=
>             return System.Text.Encoding.UTF8.GetString(data, pos, len);=0A=
78a76=0A=
> =0A=
79a78=0A=
>             int sizeConst =3D 0;=0A=
92,93c91,96=0A=
< 			for (int i =3D 0; i < nnamed; ++i) {=0A=
< 				byte type =3D data [pos++];=0A=
---=0A=
> 			for (int i =3D 0; i < nnamed; ++i)=0A=
>             {=0A=
>                 int paramType; // What is this ?=0A=
>                 paramType =3D (int)data [pos++];=0A=
>                 paramType |=3D ((int)data [pos++]) << 8;=0A=
> =0A=
96a100=0A=
> =0A=
104a109,115=0A=
>                 case "SizeConst":=0A=
>                     value =3D (int)data [pos++];=0A=
>                     value |=3D ((int)data [pos++]) << 8;=0A=
>                     value |=3D ((int)data [pos++]) << 16;=0A=
>                     value |=3D ((int)data [pos++]) << 24;=0A=
>                     sizeConst =3D value;=0A=
>                     break;=0A=
110c121,122=0A=
< 			switch ((UnmanagedType)utype) {=0A=
---=0A=
>             switch ((UnmanagedType)utype)=20
>             {=0A=
115a128=0A=
>                     return =
UnmanagedMarshal.DefineByValArray(sizeConst);=0A=
116a130=0A=
>                     return UnmanagedMarshal.DefineByValTStr(sizeConst);=0A=

------=_NextPart_000_05CF_01C2C599.CDCB0DE0--