Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Koritzinsky <jekoritz@microsoft.com>2022-08-04 21:54:08 +0300
committerGitHub <noreply@github.com>2022-08-04 21:54:08 +0300
commit4c07f3dbe5a439e5c6ac66fd14c4fed51aa819ce (patch)
tree1f9c92b5c7be70ba1446ecec2b16f01f16deacbf /src/tests/baseservices
parent614e763b9236740ed308b80b909bca63e58311fb (diff)
Enable inlining P/Invokes into try blocks with no catch or filter clauses (#73032)
Diffstat (limited to 'src/tests/baseservices')
-rw-r--r--src/tests/baseservices/exceptions/exceptioninterop/ExceptionInterop.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/tests/baseservices/exceptions/exceptioninterop/ExceptionInterop.cs b/src/tests/baseservices/exceptions/exceptioninterop/ExceptionInterop.cs
index 1c6f43e12e4..f0f479dfc55 100644
--- a/src/tests/baseservices/exceptions/exceptioninterop/ExceptionInterop.cs
+++ b/src/tests/baseservices/exceptions/exceptioninterop/ExceptionInterop.cs
@@ -122,4 +122,38 @@ public unsafe static class ExceptionInterop
Assert.True(caughtException);
}
+
+ [Fact]
+ [PlatformSpecific(TestPlatforms.Windows)]
+ [SkipOnMono("Exception interop not supported on Mono.")]
+ public static void ThrowNativeExceptionInFrameWithFinallyCatchInOuterFrame()
+ {
+ bool caughtException = false;
+ try
+ {
+ ThrowInFrameWithFinally();
+ }
+ catch
+ {
+ caughtException = true;
+ }
+
+ Assert.True(caughtException);
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static void ThrowInFrameWithFinally()
+ {
+ try
+ {
+ ThrowException();
+ }
+ finally
+ {
+ // Try calling another P/Invoke in the finally block before the catch
+ // to make sure we have everything set up
+ // to recover from the exceptional control flow.
+ NativeFunction();
+ }
+ }
+ }
}