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

Fix calling existing ctor with MethodInvoker; share tests with invokers #90796

Merged
merged 2 commits into from
Aug 22, 2023

Conversation

steveharter
Copy link
Member

@steveharter steveharter commented Aug 18, 2023

Refactored the existing MethodInfo\ConstructorInfo tests so they can also run under the new invoker classes MethodInvoker\ConstructorInvoker; they are run in both a forced-interpreted and a forced-emit mode for additional coverage.

This uncovered two edge case issues (fixed in this PR) that only affect the new invoker classes that were added in Preview 7:

  • Calling a constructor on an existing instance with a MethodInvoker now works as expected: the obj parameter's constructor is invoked and null is returned; this is consistent with ConstructorInfo.Invoke(obj, ...)
  • Calling a constructor invoker on abstract base class or attempting to call static constructor will now always throw MemberAccessException (same exception type used for similar cases). Calling static constructors can still be done with ConstructorInfo but since that is rare, adds overhead, and is not supported on NativeAOT, support wasn't added to MethodInvoker or ConstructorInvoker.

No tests were removed except for the invoker test "ExistingInstance()" which was already covered in the shared tests.

These changes should be ported to v8\RC2 since they only affect the new APIs added in Preview 7 and will avoid a breaking change in v9.

@ghost
Copy link

ghost commented Aug 18, 2023

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

Issue Details

[verifying tests]

Author: steveharter
Assignees: steveharter
Labels:

area-System.Reflection

Milestone: -

@jkotas
Copy link
Member

jkotas commented Aug 20, 2023

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

LGTM (Please check that the affected tests are passing in the extra-platforms legs before merging.)

@steveharter
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@steveharter
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@steveharter
Copy link
Member Author

CI failures in runtime-extra-platforms appear consistent with other recent PRs including #90836 and #90864.

Created some known issues to help filter the errors in the future. Also, there's some infra work needed so failures running runtime-extra-platforms show all of the unknown failures (currently just the first 4 are shown).

@steveharter steveharter merged commit 6b67caa into dotnet:main Aug 22, 2023
231 of 245 checks passed
@steveharter steveharter deleted the InvokerTests branch August 22, 2023 20:51
@steveharter
Copy link
Member Author

/backport to release/8.0

1 similar comment
@jkotas
Copy link
Member

jkotas commented Aug 23, 2023

/backport to release/8.0

@github-actions
Copy link
Contributor

Started backporting to release/8.0: https://github.com/dotnet/runtime/actions/runs/5945904726

@ghost ghost locked as resolved and limited conversation to collaborators Sep 22, 2023
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.

3 participants