[mono-vb] VB Class status

Rob.Tillie@Student.tUL.EDU Rob.Tillie@Student.tUL.EDU
Thu, 24 Jun 2004 00:05:05 +0200


Yes, I noticed yesterday that the default values aren't working at all =
when
Jumbunathan sent me a sample that didn't run.
The program was compiled using VB.NET compiler, and run using mono. So =
I
guess we're doing something wrong specifying the default value?

Greetz,
-- Rob.

> -----Original Message-----
> From: A Rafael D Teixeira [mailto:rafaelteixeirabr@hotmail.com]
> Sent: Wednesday, June 23, 2004 9:44 PM
> To: kjambunathan@novell.com; mono-vb@lists.ximian.com
> Cc: mono-devel-list@lists.ximian.com
> Subject: Re: [mono-vb] VB Class status
>=20
> Inline
>=20
> >From: "Jambunathan Jambunathan" <kjambunathan@novell.com>
> >
> >The errors in Microsoft.VisualBasic may seem intimidating at first.
> >Most of the errors are due to a mismatch in the Parameter =
Attributes.
> >
> >Many VB functions/methods support optional parameters with a default
> >value. MS's dll marks the Parameter with Optional, HasDefault
> >attributes.
> >
> >In our C# implementation of the method, we mark such parameters =
using
> >the
> >following two attributes: System.Runtime.InteropServices.Optional
> >and System.ComponentModel.DefaultValue(). As a result Mono's dll has
> >Parameter Attributes just set to Optional ( but has no HasDeafult ).
> >
> >I am not sure whether this is bug or a baggage not carried from the
> >past.
> >( Quick googling suggested that just using C# it's not possible to
> >create a parameter with Parameter Attributes set to Optional |
> >HasDeafult.
> >
> >Just posting to the mailing list with the hope that I will get a =
quick
> >response.
>=20
> It's indead trickier:
>=20
> code like
>=20
>    Private Sub x(ByVal w As String, Optional ByVal y As Integer =3D =
132)
>         TextBox1.Text =3D w & y
>     End Sub
>=20
>     Private Sub z()
>         x("what", 1)
>         x("whatnot")
>     End Sub
>=20
> generates things like
>=20
> .method private instance void  x(string w,
>                                  [opt] int32 y) cil managed
> {
>   .param [2] =3D int32(0x00000084)
>   .maxstack  8
>   IL_0000:  nop
>   IL_0001:  ldarg.0
> ...
>   IL_001a:  ret
> } // end of method Form1::x
>=20
> <comments>
> we need to generate it properly for MS.VB.Dll but we still need more
> information to know how. What makes that .param [n] appear there? =
[opt]
> comes from the Optional attribute? it seems so, but ...
>=20
> That is why I guessed DefaultValue, but it seems it is not the proper
> thing
> to use...
>=20
> Maybe our truly Jackson of mono=B4s ilasm fame can bear some light =
for us...
> </comments>
>=20
> and
>=20
> .method private instance void  z() cil managed
> {
>   .maxstack  8
>   IL_0000:  nop
>   IL_0001:  ldarg.0
>   IL_0002:  ldstr      "what"
>   IL_0007:  ldc.i4.1
>   IL_0008:  callvirt   instance void TesteXmlNText.Form1::x(string,
>                                                             int32)
>   IL_000d:  nop
>   IL_000e:  ldarg.0
>   IL_000f:  ldstr      "whatnot"
>   IL_0014:  ldc.i4     0x84
>   IL_0019:  callvirt   instance void TesteXmlNText.Form1::x(string,
>                                                             int32)
>   IL_001e:  nop
>   IL_001f:  nop
>   IL_0020:  ret
> } // end of method Form1::z
>=20
> <comments>
> that mbas must take care to generate, see that the compiler discover =
the
> default value and pass it
> to the method, but it complicates even more when you add overload-
> resolution
> to the figure, and also late-binding (we will have to implement all =
that
> policies inside the helping classes in MS.VB.dll also).
> </comments>
>=20
> So indeed a long way to go,
>=20
> Have fun boys,
>=20
> Rafael "Monoman" Teixeira
> Mono Hacker since 16 Jul 2001 - http://www.go-mono.org/
> MonoBrasil Founding Member - Membro Fundador do MonoBrasil
> http://monobrasil.softwarelivre.org
> English Blog: http://monoblog.blogspot.com/
> Brazilian Portuguese Blog: http://monoblog.weblogger.terra.com.br/
>=20
> _________________________________________________________________
> MSN Messenger: instale gr=E1tis e converse com seus amigos.
> http://messenger.msn.com.br
>=20
> _______________________________________________
> Mono-vb mailing list
> Mono-vb@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-vb