stiletto icon indicating copy to clipboard operation
stiletto copied to clipboard

Discover entry-points via codegen

Open benjamin-bader opened this issue 12 years ago • 1 comments

Pros:

  • remove stupid Injects = new[] { typeof(Foo) } boilerplate

Cons:

  • Inheritance complicates this
  • Container.Add complicates this
    • At some point, we have to determine just what modules are being added
    • The common pattern of base.OnCreate { Container.Add(GetModules()).Inject(this, GetType()); } seems hard to analyze reliably
  • Generics? Ugh

benjamin-bader avatar Jul 03 '13 20:07 benjamin-bader

This needs some deep thought. The API would be so much more usable, but only if codegen actually works beyond the 80% case. For example, how to support this;

public T Get<T>()
{
    return this.Container.Get<T>();
}

Naively, we could just search the whole world for calls to Get, and look at their generic arguments. And what if those arguments are themselves generic? How deeply should we look?

benjamin-bader avatar Jul 07 '13 06:07 benjamin-bader