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

Add possibility to add AWS services to DI with a key #3570

Merged
merged 2 commits into from
Dec 13, 2024

Conversation

OleksiiZuiev
Copy link

Description

Add the possibility to add AWS services to DI with a key, utilizing Keyed services feature of the framework.

The change relies on the framework feature that was introduced in .NET8. If target framework is 8, newer dependencies of Microsoft.Extensions.DependecyInjection , Microsoft.Extensions.DependencyInjection.Abstractions are referenced and extention methods to IServiceCollection are added.

AddKeyedAwsService and TryAddKeyedAwsService are added with 2 overloads for each, to align with extension methods that add services without a key.

Motivation and Context

This feature allows to add multiple registrations of a single service type. This enables cases when different instances of a service need to have different AWS options. One of the cases is described in issue #3561

Testing

I extended DependencyInjectionTests in NETCore.SetupTests and ensured they all pass.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

Copy link
Member

@normj normj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Looks good.

@normj
Copy link
Member

normj commented Dec 13, 2024

Merging after pulling in branch and successfully running internal full build against the branch.

@normj normj merged commit 6215931 into aws:v4-development Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants