[Mono-devel-list] Microsoft.VisualBasic.dll gets support for default values for optional parameters
radical at gmail.com
Thu Apr 21 07:41:38 EDT 2005
A long known problem with mono for VB.Net developers was that
Microsft.VisualBasic.* didn't support default values for optional
parameters. The problem has been nicely explained by Jambu at
http://www.gnomebangalore.org/?q=node/view/498. I had written about it
in my blog about a month back.
In short, the problem is that Microsoft.VisualBasic.* has been written
in C#, and since C# doesn't have a concept of default values or
optional parameters.. these cant be represented in a straight-forward
manner. So, Jambu created a DefaultArgumentValueAttribute which could
be used for a method parameter to specify its default value. But this
has to be converted from being a custom attribute to actual metadata
in dll as the default value.
So, the idea is -> dissassemble Microsoft.VisualBasic.dll -->
fixup_with_script --> assemble back.
Writing the script wasnt much of a problem, but it turned out that
monodis and ilasm had *some* bugs cos of which the "roundtrip" wouldnt
work (http://mono-nosip.blogspot.com/). So, after a long series of bug
fixes to ilasm/monodis/runtime(small fixes) .. the roundtripping is
Hari has integerated the script with the build system. So, nothing
extra needs to be done to take advantage of this now. You can use
methods in Microsoft.VisualBasic.dll which have optional parameters
sub Main ()
Console.WriteLine (Strings.Format (5459.4))
Strings.Format takes two parameters, the 2nd one being optional !
Though, i've tried to test the *fixedup_dll*, there will probably be
things that i havent encountered, so would be eagerly waiting for
Special thanks to Hari for this entire work.
Mono hacking : http://mono-nosip.blogspot.com
Personal : http://www.corewars.org/radical
More information about the Mono-devel-list