Not a solution that works all the time but this will do for most part:
class GenericControlDescriptionProvider : TypeDescriptionProvider
{
public GenericControlDescriptionProvider()
: base(TypeDescriptor.GetProvider(typeof(ContainerControl)))
{
}
public override Type GetReflectionType(Type objectType, object instance)
{
if (objectType.IsGenericType)
{
return objectType.BaseType;
}
return base.GetReflectionType(objectType, instance);
}
public override object CreateInstance(IServiceProvider provider, Type objectType, Type[] argTypes, object[] args)
{
if (objectType.IsGenericType)
{
objectType = objectType.BaseType;
}
return base.CreateInstance(provider, objectType, argTypes, args);
}
}
All I am checking for is if the target type is generic, if so use its base class. The assumption here is that the base class is a proper instantiable class for the designer. An example:
[TypeDescriptionProvider(typeof(GenericControlDescriptionProvider))]
public abstract class FormBase<TViewModel> : Form
Tested for VS 2017, .NET 4.5.2. The catch is solution (read the presentation project) has to be built once for the lifetime of the VS process. Every time you start VS, you need to build once, that's all.