I have a very thin interface that’s going to define one method. Should I require the type parameter on the class definition?
public interface ISomethingFun<T> { void Do(T item); }
or method definition?
public interface ISomethingFun { void Do<T>(T item); }
What rationale? Is one easier to implement, inherit, or generate dynamically? Is it style? Is there some OO guidance that applies?
The advantage to having the generic on the method is that it facilitates type inference.
There you go, a completely generic call, no generic parameters. Putting the generic Parameter on the type forces you to add generic signatures or bindings whenever the type is shown in metadata
This is not necessarily a bad thing and is in fact often necessary. It’s just a difference.
In general though, if every method has the same generic parameter, just add it to the type 🙂