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

Missing Lambda expression variable name #33676

Open
rajanmishra18 opened this issue Sep 22, 2024 · 3 comments
Open

Missing Lambda expression variable name #33676

rajanmishra18 opened this issue Sep 22, 2024 · 3 comments
Labels

Comments

@rajanmishra18
Copy link

Description

[Enter feedback here]
Inside ConfigureService while implementing IMiddlewareFactory variable name is only _ while _container is being used.

services.AddTransient<IMiddlewareFactory>(_ => { return new SimpleInjectorMiddlewareFactory(_container); });
This should be replaced with

services.AddTransient<IMiddlewareFactory>(_container => { return new SimpleInjectorMiddlewareFactory(_container); });

Page URL

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/extensibility-third-party-container?view=aspnetcore-8.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/middleware/extensibility-third-party-container.md

Document ID

ea1db4c0-e8cc-98e8-a235-8c80e9a8f395

Article author

@Rick-Anderson

@Rick-Anderson
Copy link
Contributor

@rajanmishra18 good catch. The sample should be updated to the minimal hosting model. Looks like that update was done or at least started here

@rajanmishra18 would you be interested in fixing the sample/doc?

@serpent5 do you know what happened in #25427 ?

@rajanmishra18
Copy link
Author

rajanmishra18 commented Sep 23, 2024 via email

@serpent5
Copy link
Contributor

serpent5 commented Sep 23, 2024

In terms of the change suggested here...

Because the parameter passed into the AddTransient callback is IServiceProvider, and not Container, the example change won't compile. The reason it's named as _ in the example is because it's being discarded (it's unused). I think the example implies that _container is a field within Startup, and it's just being passed into SimpleInjectorMiddlewareFactory when it's created as transient service.

@Rick-Anderson It looks like #25427 was for "Factory-based middleware activation in ASP.NET Core", but this here is for "Middleware activation with a third-party container in ASP.NET Core". I didn't do anything with this topic, perhaps because it had fewer monthly views and was lower on the priority list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: To do
Development

No branches or pull requests

4 participants