Skip to content
New issue

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

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

Already on GitHub? # to your account

Amazon.Lambda.Annotations: allow an alternate IServiceProvider implementation #1729

Open
2 tasks
chrischappell-rgare opened this issue Apr 12, 2024 · 4 comments
Labels
annotations feature-request A feature should be added or improved. p2 This is a standard priority issue queued

Comments

@chrischappell-rgare
Copy link

Describe the feature

Provide a way of using an inversion of control container other than the default Microsoft.Extensions.DependencyInjection.

Use Case

I would like to be able to use Autofac with Amazon.Lambda.Annotations.

Proposed Solution

A formal api around a Startup class would work, but it looks like a small tweak to the generated code may be sufficient to hook in an alternate IServiceProvider.

The serviceProvider is currently stored in a field defined like this:
private readonly ServiceProvider serviceProvider;

The field is using the concrete type ServiceProvider. If the field type were changed to IServiceProvider that would allow a different IServiceProvider to be used by implementing a BuildServiceProvider extension method in the Lambda project.

public static AutofacServiceProvider BuildServiceProvider(this IServiceCollection services)
{
      var builder = new ContainerBuilder();
      builder.Populate(services);
      return new AutofacServiceProvider(builder.Build());
}

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS .NET SDK and/or Package version used

Amazon.Lambda.Annotations 1.3.0

Targeted .NET Platform

.Net 8

Operating System and version

AmazonLinux

@chrischappell-rgare chrischappell-rgare added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Apr 12, 2024
@ashishdhingra
Copy link
Contributor

Appears to be a useful feature request. Needs review with the team.

@ashishdhingra ashishdhingra added needs-review p2 This is a standard priority issue queued and removed needs-triage This issue or PR still needs to be triaged. needs-review labels Apr 15, 2024
@normj
Copy link
Member

normj commented Apr 19, 2024

This is a valid feature request. We will need more upvotes to prioritize this work. If you are interested in contributing a PR to add support I would be happy to review it.

@werebear73
Copy link

Upvote

@ItsSmiffy
Copy link

Would also like to use it with SimpleInjector. Upvote.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
annotations feature-request A feature should be added or improved. p2 This is a standard priority issue queued
Projects
None yet
Development

No branches or pull requests

5 participants