-
Notifications
You must be signed in to change notification settings - Fork 764
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow multiple types to be registered for one name
Fixes: dotnet/aspnetcore#13346 In 3.0 we added validation to try and report exceptions for some common HttClient factory usage mistakes in the registration code. Unfortunately we blocked from legitimate usage cases. In this case, users are blocked from associating multiple types with the same logical 'name'. Ex: ```C# services.AddHttpClient("Foo").AddTypedClient<A>().AddTypedClient<B>(); ``` This is useful and should be allowed because it's a good way to DRY up configuration code. ---- This change relaxes the validation when `AddTypedClient` is called, but not when `AddHttpClient` is called without supplying a name. We still want to block cases like the following: ```C# services.AddHttpClient<A.SomeClient>(); services.AddHttpClient<B.SomeClient>(); ``` The type short name is used as the logical name for the client (named options) so usage like this is always a bug.
- Loading branch information
Showing
3 changed files
with
143 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters