Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ActivatorUtilities.CreateInstance() should respect [ActivatorUtilitiesConstructor]#99175

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
steveharter merged 4 commits intodotnet:mainfromsteveharter:DiCtor
Mar 6, 2024

Conversation

steveharter
Copy link
Contributor

@stevehartersteveharter commentedMar 1, 2024
edited
Loading

The current approach of selecting constructors uses[ActivatorUtilitiesConstructor] in an odd manner that even when a constructor has the attribute, it may not be called depending on the ordering of constructors and the number of constructor parameters. This PR changes to always call the constructor that has that attribute.

Current approach:

  1. Reads constructors in order declared (according to the compiler and the order metadata was written).
  2. Picks the constructor with the most parameters.
  3. If there is a constructor with[ActivatorUtilitiesConstructor] then that constructor is selected, no matter how many parameters are present. Only one constructor can have the attribute.
  4. If there is another constructor with the same or more parameters after[ActivatorUtilitiesConstructor] was found, then that is selected.

Proposed approach: from the current approach above, remove (4) which makes (1) no longer applicable.

This address a case from#98959 where ordering of the constructors can cause a constructor that has[ActivatorUtilitiesConstructor] to not be selected if comes before a different constructor with the same parameter count, and also fully addresses the issues raised in#42339 (comment).

cc@tarekgh,@eerhardt

@ghost
Copy link

Tagging subscribers to this area: @dotnet/area-extensions-dependencyinjection
See info inarea-owners.md if you want to be subscribed.

Issue Details

Address a case from#98959 where ordering of the constructors can cause a constructor that has[ActivatorUtilitiesConstructor] to not be selected if comes before a different constructor with the same parameter count.

cc@tarekgh,@eerhardt

Author:steveharter
Assignees:steveharter
Labels:

area-Extensions-DependencyInjection

Milestone:-

Copy link
Member

@tarekghtarekgh left a comment

Choose a reason for hiding this comment

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

LGTM, I hope the breaking change will not cause any issue. At least now we are behaving as our docs describe.

@stevehartersteveharter merged commitbb919c2 intodotnet:mainMar 6, 2024
@stevehartersteveharter deleted the DiCtor branchMarch 6, 2024 14:58
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsApr 7, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@david-driscolldavid-driscolldavid-driscoll left review comments

@tarekghtarekghtarekgh approved these changes

@buyaa-nbuyaa-nAwaiting requested review from buyaa-n

Assignees

@stevehartersteveharter

Labels
area-Extensions-DependencyInjectionbreaking-changeIssue or PR that represents a breaking API or functional change over a prerelease.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@steveharter@david-driscoll@tarekgh@jkotas

[8]ページ先頭

©2009-2025 Movatter.jp