Skip to content

[ObjCRuntime] Unwrap TargetInvocationExceptions we get when invoking methods using reflection.#11733

Merged
rolfbjarne merged 1 commit into
dotnet:mainfrom
rolfbjarne:coreclr-unwrap-targetinvocationexceptions
May 31, 2021
Merged

[ObjCRuntime] Unwrap TargetInvocationExceptions we get when invoking methods using reflection.#11733
rolfbjarne merged 1 commit into
dotnet:mainfrom
rolfbjarne:coreclr-unwrap-targetinvocationexceptions

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

Fixes this unit test:

[FAIL] ManagedExceptionPassthrough :   exception
 Expected: same as <System.ApplicationException: 3,14
  at MonoTouchFixtures.ObjCRuntime.ExceptionsTest.ManagedExceptionTest.ThrowManagedException() in xamarin-macios/tests/monotouch-test/ObjCRuntime/ExceptionsTest.cs:line 128>
 But was:  <System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.ApplicationException: 3,14
  at MonoTouchFixtures.ObjCRuntime.ExceptionsTest.ManagedExceptionTest.ThrowManagedException() in xamarin-macios/tests/monotouch-test/ObjCRuntime/ExceptionsTest.cs:line 128
  --- End of inner exception stack trace ---
  at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
  at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in System.Private.CoreLib.dll:token 0x6004d2a+0x0
  at ObjCRuntime.Runtime.InvokeMethod(MethodBase method, Object instance, IntPtr native_parameters) in Xamarin.Mac.dll:token 0x60011d1+0x254
  at ObjCRuntime.Runtime.InvokeMethod(MonoObject* methodobj, MonoObject* instanceobj, IntPtr native_parameters) in Xamarin.Mac.dll:token 0x60011d0+0x0
  at ObjCRuntime.Runtime.bridge_runtime_invoke_method(MonoObject* method, MonoObject* instance, IntPtr parameters, IntPtr& exception_gchandle) in Xamarin.Mac.dll:token 0x6001124+0x26
  at ApiDefinition.Messaging.void_objc_msgSendSuper(IntPtr receiver, IntPtr selector)
  at Bindings.Test.ObjCExceptionTest.InvokeManagedExceptionThrower() in xamarin-macios/tests/xharness/tmp-test-dir/monotouch-test2683/obj/Debug/net6.0-macos/macOS/Bindings.Test/ObjCExceptionTest.g.cs:line 105
  at MonoTouchFixtures.ObjCRuntime.ExceptionsTest.ManagedExceptionPassthrough() in xamarin-macios/tests/monotouch-test/ObjCRuntime/ExceptionsTest.cs:line 154>
  at MonoTouchFixtures.ObjCRuntime.ExceptionsTest.ManagedExceptionPassthrough() in xamarin-macios/tests/monotouch-test/ObjCRuntime/ExceptionsTest.cs:line 159

…methods using reflection.

Fixes this unit test:

    [FAIL] ManagedExceptionPassthrough :   exception
     Expected: same as <System.ApplicationException: 3,14
      at MonoTouchFixtures.ObjCRuntime.ExceptionsTest.ManagedExceptionTest.ThrowManagedException() in xamarin-macios/tests/monotouch-test/ObjCRuntime/ExceptionsTest.cs:line 128>
     But was:  <System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
    ---> System.ApplicationException: 3,14
      at MonoTouchFixtures.ObjCRuntime.ExceptionsTest.ManagedExceptionTest.ThrowManagedException() in xamarin-macios/tests/monotouch-test/ObjCRuntime/ExceptionsTest.cs:line 128
      --- End of inner exception stack trace ---
      at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
      at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in System.Private.CoreLib.dll:token 0x6004d2a+0x0
      at ObjCRuntime.Runtime.InvokeMethod(MethodBase method, Object instance, IntPtr native_parameters) in Xamarin.Mac.dll:token 0x60011d1+0x254
      at ObjCRuntime.Runtime.InvokeMethod(MonoObject* methodobj, MonoObject* instanceobj, IntPtr native_parameters) in Xamarin.Mac.dll:token 0x60011d0+0x0
      at ObjCRuntime.Runtime.bridge_runtime_invoke_method(MonoObject* method, MonoObject* instance, IntPtr parameters, IntPtr& exception_gchandle) in Xamarin.Mac.dll:token 0x6001124+0x26
      at ApiDefinition.Messaging.void_objc_msgSendSuper(IntPtr receiver, IntPtr selector)
      at Bindings.Test.ObjCExceptionTest.InvokeManagedExceptionThrower() in xamarin-macios/tests/xharness/tmp-test-dir/monotouch-test2683/obj/Debug/net6.0-macos/macOS/Bindings.Test/ObjCExceptionTest.g.cs:line 105
      at MonoTouchFixtures.ObjCRuntime.ExceptionsTest.ManagedExceptionPassthrough() in xamarin-macios/tests/monotouch-test/ObjCRuntime/ExceptionsTest.cs:line 154>
      at MonoTouchFixtures.ObjCRuntime.ExceptionsTest.ManagedExceptionPassthrough() in xamarin-macios/tests/monotouch-test/ObjCRuntime/ExceptionsTest.cs:line 159
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

❌ [PR Build] Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

API & Generator diff

API Diff (from PR only) (no change)
Generator Diff (no change)

GitHub pages

Results can be found in the following github pages (it might take some time to publish):

Test results

2 tests failed, 107 tests passed.

Failed tests

  • monotouch-test/Mac [dotnet]/Debug (CoreCLR) [dotnet]: Failed (Test run failed.
    Tests run: 2444 Passed: 2354 Inconclusive: 7 Failed: 3 Ignored: 87)
  • monotouch-test/Mac [dotnet]/Debug (CoreCLR, static registrar) [dotnet]: Failed (Test run failed.
    Tests run: 2441 Passed: 2354 Inconclusive: 7 Failed: 1 Ignored: 86)

Pipeline on Agent XAMBOT-1096.BigSur'
Merge 8602b28 into 51c9364

@rolfbjarne

Copy link
Copy Markdown
Member Author

@rolfbjarne rolfbjarne merged commit 8d6893c into dotnet:main May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

not-notes-worthy Ignore for release notes run-dotnet-tests Run all the .NET tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants