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] Fix argument validation in RuntimeType.InvokeMember #75006

Merged
merged 1 commit into from
Sep 6, 2022

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 2, 2022

Backport of #74998 to release/7.0

/cc @stephentoub

Customer Impact

Type.InvokeMember has historically allowed the member name argument to be null when specifying BindingFlags.CreateInstance, since in that case Activator.CreateInstance is used and the member name is ignored. But the overhaul earlier in the release to use !! and then again to use ArgumentNullException.ThrowIfNull erroneously resulting in the null check for non-CreateInstance cases being moved earlier in the method. The net result is passing a null name with BindingFlags.CreateInstance now throws an ArgumentNullException rather than successfully instantiating the object. This fixes that to put the throw back where it should have been.

Testing

New automated test, plus all CI testing plus local runs of the reflection tests.

Risk

Minimal

The rollout of `!!` erroneously moved an ArgumentNullException to be thrown earlier in the method, preventing a null name from being used (which is valid with BindingFlags.CreateInstance).

(Separately, we should consider fixing the nullable reference type annotation on `string name`, since null is allowed in some circumstances.)
@ghost
Copy link

ghost commented Sep 2, 2022

Tagging subscribers to this area: @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #74998 to release/7.0

/cc @stephentoub

Customer Impact

Testing

Risk

IMPORTANT: Is this backport for a servicing release? If so and this change touches code that ships in a NuGet package, please make certain that you have added any necessary package authoring and gotten it explicitly reviewed.

Author: github-actions[bot]
Assignees: -
Labels:

area-System.Reflection

Milestone: -

@carlossanlop
Copy link
Member

@buyaa-n / @steveharter / @AaronRobinsonMSFT need a code review sign off, please.
@danmoseley (or @jeffhandley on Dan's behalf), need a backport approval for this.

@jeffhandley
Copy link
Member

Approved for backport. Regression from previous release.

@carlossanlop
Copy link
Member

Approved, signed off, CI green. Ready to merge. :shipit:

@carlossanlop carlossanlop merged commit ff921f6 into release/7.0 Sep 6, 2022
@carlossanlop carlossanlop deleted the backport/pr-74998-to-release/7.0 branch September 6, 2022 18:35
@ghost ghost locked as resolved and limited conversation to collaborators Oct 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants