Skip to content

Update runtime Invoke exception handling #67457

@steveharter

Description

@steveharter

Description

There are some exception behavioral changes in the native Core Invoke implementation in #66357. Previously, exceptions thrown by the native code were not wrapped with TargetInvocationException and now they are. Mono should uptake these changes.

The changes are consistent with other exceptions thrown when Invoking - mainly exceptions are not wrapped when the caller's parameters are bad (wrong number of arguments, or wrong types) but are wrapped when the Target throws or does something incorrectly. This change also facilitates the design to move native code to managed by performing validation logic on the managed side and allows for other implementations of Invoke (such as future IL-emit version) to be simpler.

A breaking change issue will be created for consumers, but for now the Mono runtime should adjust to this by not catching these exceptions specially and let the normal TargetInvocationException logic wrap the exceptions.

Reproduction Steps

See the tests flags with ActiveIssue for this issue.

Expected behavior

The Mono runtime should let exceptions be re-thrown as TargetInvocationException.

Actual behavior

The Mono runtime does not re-throw as TargetInvocationException.

Regression?

Not really; semantic \ breaking change.

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions