CarterCommunity / Carter

Carter is framework that is a thin layer of extension methods and functionality over ASP.NET Core allowing code to be more explicit and most importantly more enjoyable.
MIT License
2.08k stars 175 forks source link

Base module an DI issue #201

Closed jchannon closed 2 years ago

jchannon commented 5 years ago

You get a DI error when you have the following

 public class ApiModule : CarterModule
    {
        public ApiModule(string modulePath) : base("/api" + modulePath)
        {
        }
    }

public class FooModule : ApiModule
{
  public FooModule() : base("/foo"){}
}
poke commented 4 years ago

You could simply make the ApiModule abstract to avoid this.

Otherwise, how do you envision this to work? Carter will automatically look for modules and attempt to instantiate them. So when it finds ApiModule, it tries to create that one but fails because it cannot resolve modulePath.