[Mono-dev] Patch to Fix CanConvertTo and ConverTo of/for primitive types.

Ivan Zlatev ivan at ivanz.com
Thu Jan 21 14:47:51 EST 2010


Hi and sorry for the delay,

I think that I am the last to have touched the
System.ComponentModel(.Design) namespaces and I think this patch looks
good.

Kind Regards,

Ivan Zlatev
http://ivanz.com



On Wed, Jan 20, 2010 at 8:05 PM, Alexandre Miguel Pedro Gomes
<alexmipego at gmail.com> wrote:
> 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
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>


More information about the Mono-devel-list mailing list