I've been thinking about static interfaces, and I think they would be really useful for software which uses reflection to identify and assemble components. Currently I find myself having to design around this limitation with unnecessary factories or by enforcing
conditions at runtime (like checking for methods and throwing exceptions if they aren't present).
It would be great if the following was possible:
foreach (var type in Assembly.GetExecutingAssembly().GetTypes().Where(t => t is IStaticInterfaceType)) (type as IStaticInterfaceType).StaticMethod();
This could be used for singleton patterns, initialization methods, registration methods, or any number of other things.
I don't know how much overhead this would introduce, but perhaps this would be possible by making every class have its own corresponding Type. This type would be derived from Type and would implement the static interfaces for the type.
This would allow for much safer use of reflection (which is a brilliant tool for keeping things modular and for reducing code bulk).
I've only just started thinking about this and would love to get some outside opinions (or explanations of why this isn't feasible).