[Mono-dev] Patch to Fix CanConvertTo and ConverTo of/for primitive types.
Alexandre Miguel Pedro Gomes
alexmipego at gmail.com
Wed Jan 20 15:05:37 EST 2010
Hi again,
Can't anyone review or comment on it? Where is the maintainer for the
System.ComponentModel modules?
I would really like to have this committed ASAP so I can avoid patching my
sources when the next minor revision of Mono is released.
Cheers,
On Fri, Jan 15, 2010 at 20:28, Alexandre Miguel Pedro Gomes <
alexmipego at gmail.com> wrote:
> Hi,
>
> I've detected a problem with type convertion when using the TypeConverters
> for a type. My initial test case for comparing Mono 2.4.* and trunk results
> with the .Net framework was as such:
>
> -- code --
> using System;
> using System.ComponentModel;
>
> namespace PrimitiveTests
> {
> class Program
> {
> static void Main(string[] args)
> {
> Type[] types = { typeof(Boolean),
> typeof(Byte),
> typeof(SByte),
> typeof(Int16),
> typeof(UInt16),
> typeof(Int32),
> typeof(UInt32),
> typeof(Int64),
> typeof(UInt64),
> typeof(IntPtr),
> typeof(UIntPtr),
> typeof(Char),
> typeof(Double),
> typeof(Single)};
>
> foreach(Type type in types)
> Console.WriteLine("CanConvert " + type + " to Int32? " +
> TypeDescriptor.GetConverter(type).CanConvertTo(typeof(Int32)));
>
>
> Console.WriteLine(TypeDescriptor.GetConverter(typeof(uint)).ConvertTo((uint)134,
> typeof(int)));
>
> Console.ReadKey();
> }
> }
> }
> -- code --
>
> This revealed that all primitives with a few exceptions (bool, intptr,
> char) should be allowed to be converted and Mono's CanConvertTo (and the
> actual conversion) was failing. I've created a patch and necessary unit
> tests to fix the issue and tested both with the previous script and with my
> (now patched) Mono 2.4.3 server's install.
>
> If someone could review, it would be appreciated. I can commit if the
> maintainer approves the code.
>
> Regards,
>
> --
> Alexandre Gomes
> http://www.alexandre-gomes.com
>
--
Alexandre Gomes
http://www.alexandre-gomes.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20100120/b314fb07/attachment-0001.html
More information about the Mono-devel-list
mailing list