I have a method of an object which is something like a factory. You give it a type, it creates an instance and does a few other things. An elegant way to do it (in my opinion) is like this:
public T MagicMethod<T>() where T: SomeBaseClass
{
// Magic goes here
}
But this upsets FxCop who says that this is a bad style - I get a "CA1004: Generic methods should provide type parameter" warning. Something about not being to use inference and stuff. So, the only other way I can think of is something like this:
public SomeBaseClass MagicMethod(Type T)
{
// Same magic goes here
}
I believe this is inferior to the first method on many accounts, but the style rule... The MSDN article on the warning even says that there is no reason for suppressing it.
Am I doing it right by suppressing this warning after all?