Assigining a TypeConverter to a class you don't own
In this post, I describe a solution to a problem I encountered while working with XNA Beta1 and Vector2 structs. Because Vector2 didn't have an associated TypeConverter, the designer lacked support. Applying a TypeConverter to the property worked in the designer, but Visual Studio 2005 ignored it during serialization, resorting to resource files, which was messy. My workaround involves dynamically adding a TypeConverter to the Vector2 type itself using TypeDescriptor.AddAttributes, which is invoked during the class's construction. By registering the Vector2Converter with the Vector2 type early on, both the designer and code serialization work harmoniously.