Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Hypodermic Great Again! Autowiring constructors with dependencies which are not available at the compile time. #61

Open
skalinkin opened this issue Dec 9, 2024 · 2 comments

Comments

@skalinkin
Copy link

skalinkin commented Dec 9, 2024

Hi everyone,

We love Hypodermic, and we're excited to use it in our project! However, we need your help.

Our team is transitioning from a C# background to a C++ project. Since we previously used Autofac with .NET, Hypodermic was a natural choice for us.

We like to organize our code into packages, which means we often build packages with abstract classes as dependencies known at compile time. Unfortunately, we're encountering exceptions related to not being able to autowire constructors when registering types for these dependencies.

To work around this, we're using registerInstanceFactory with lambdas. However, managing and maintaining thousands of such factories introduces a lot of "accidental complexity," and we’re looking for ways to simplify this process.

We understand that .NET's reflection capabilities make this easier, while C++ lacks a direct equivalent (for now). Are there any strategies to automate the registration of classes in our case? Could a preprocessor, code generation, or any other tool or approach help us avoid asking developers to manually write factories for every class?

Any advice or recommendations would be greatly appreciated!

Thanks in advance!

@ybainier
Copy link
Owner

ybainier commented Dec 9, 2024

Hello, can you provide a sample where autowiring fails on your side?

@skalinkin
Copy link
Author

Give me some time I will need to create the demo solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants