Skip to content

Lazy named services are resolved incorrectly #606

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

Open
kemsky opened this issue Mar 24, 2025 · 1 comment
Open

Lazy named services are resolved incorrectly #606

kemsky opened this issue Mar 24, 2025 · 1 comment

Comments

@kemsky
Copy link
Contributor

kemsky commented Mar 24, 2025

// Register Bar service without providing a name:
serviceContainer.Register<Bar>();

// The following code injects Lazy<Bar> but it should fail because there is no service Bar with name "some-name":
Consumer ([Inject("some-name")] Lazy<Bar> lazyBar) {
     // this also does not fail:
     Console.WriteLine(lazyBar.Value.ToString());
}

Inject attribute is effectively ignored when Lazy<> is used. According to the source code service name is not used when Lazy<> is requested.

I'm trying to use named services to create Lazy<HttpClient> automatically via RegisterFallback but this bug prevents RegisterFallback from running.

@kemsky
Copy link
Contributor Author

kemsky commented Apr 26, 2025

@seesharper , could you take a look please?

seesharper added a commit that referenced this issue Apr 27, 2025
Fixed issue #606: properly support named Lazy services
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

1 participant