gracicot / kangaru

🦘 A dependency injection container for C++11, C++14 and later
MIT License
478 stars 40 forks source link

kgr::debug::service doesn't detect an error when service doesn't inherit from kgr classes #88

Closed selat closed 2 years ago

selat commented 5 years ago

If you pass some random class (not related to dependency injection) to kgr::debug::service it doesn't report an error.

To Reproduce


struct RandomService {};

int main() {
  kgr::container container;
  kgr::debug::service<RandomService>();
  return 0;
}

Expected behavior Error message with something like "Class doesn't inherit from kgr::service".

Desktop

gracicot commented 5 years ago

Thanks for reporting. Service errors are really hard to maintain right now as they are not tested continuously. I'll take a look at it soon.

Also services are not forced to inherit from kgr::service. As long as the implementation is done correctly, the container should accept it.

gracicot commented 2 years ago

It should print the correct error message now, and there are tests to enforce this.