Sunday, January 03, 2010

TypeConverter class is broken!

Well, sort of.

I was browsing the Connect site and got a glimpse of this reported bug.

Digging a bit in the Framework I discovered that EVERY TypeConverter based class that does not override the IsValid function will always return TRUE.

The bug resides in the base TypeConverter class that has the following code:
public virtual bool IsValid(ITypeDescriptorContext context, object value)
{
return true;
}

Hence, every single TypeDescriptor that doesn't override it, will fail the most basic tests.

Shame on you MS.

So, if you ever need to create a TypeConverter derived class, ALWAYS override the IsValid function.

0 Comments:

Post a Comment