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

[release/7.0] Infer parameter source from ElementType for IEnumerable #45256

Merged
merged 4 commits into from
Nov 30, 2022

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Nov 23, 2022

Backport of #45173 to release/7.0

/cc @brunolins16

Infer parameter source from ElementType for IEnumerable

This PR addresses a bug shipped in .NET 7 where a parameter (IEnumerable<>) is incorrectly detected as FromService.

Fixes #45162

Customer Impact

In .NET 7 was introduced, in API Controllers and SignalR, the feature to infer the source (FromServices) for parameter types registered in the DI, however, the mechanism always detects IEnumerable<> as a type registered, since the CallSiteFactory is not explicit registering them and could they be created when requested, changing (unexpected) the behavior from .NET 6.

This PR fixes both (API Controllers and SignalR) to when a IEnumerable<> parameter type is detected uses the Type Argument instead to check if it is registered in the DI, reverting to the .NET 6 behavior and keep the feature working.

Regression?

  • Yes
  • No

The usage of IEnumerable<> parameters was working on .NET 6 and the regression introduced in .NET 7.

Risk

  • High
  • Medium
  • Low

This change is very limited to how the inference works and not changing the parameter binding itself.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

@github-actions github-actions bot requested review from BrennanConroy, halter73 and a team as code owners November 23, 2022 23:23
@brunolins16 brunolins16 requested a review from a team November 24, 2022 00:22
@brunolins16 brunolins16 added area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels Servicing-consider Shiproom approval is required for the issue labels Nov 24, 2022
@ghost
Copy link

ghost commented Nov 24, 2022

Hi @github-actions[bot]. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge.

To learn more about how to prepare a servicing PR click here.

@brunolins16
Copy link
Member

Service approved by email. @dotnet/aspnet-build can someone help me with this PR merge?

@brunolins16 brunolins16 added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Nov 30, 2022
@ghost
Copy link

ghost commented Nov 30, 2022

Hi @github-actions[bot]. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed.

@dougbu dougbu merged commit b9e4f66 into release/7.0 Nov 30, 2022
@dougbu dougbu deleted the backport/pr-45173-to-release/7.0 branch November 30, 2022 06:55
@dougbu dougbu added this to the 7.0.2 milestone Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants