3 ms·
In production, yes - but in most unit and integration test code projects you still provide explicit constructor parameters. Many frameworks also provide for de
by DaiPlusPlus 7y ago
In production, yes - but in most unit and integration test code projects you still provide explicit constructor parameters.
Many frameworks also provide for dependency validation that can be performed when the program first starts-up - you can then extend your build process to execute this validation code as part of a CI/CD process - so while it’s not strictly speaking compiler-enforced correctness it’s still better than getting a nasty surprise in production.
Aside: I‘d love to see a T4-based static DI object factory for my .NET projects which would be the best of both worlds: full static compiler-enforced dependency correctness without needing to code it by hand. It should be possible to make using EnvDTE or Roslyn. Would anyone be interested in that?