Skip to content

Commit 0087cf3

Browse files
Don't set MarshalManagedExceptionMode.UnwindNativeCode for CoreCLR
1 parent 3e4af30 commit 0087cf3

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/Sentry.Bindings.Cocoa/buildTransitive/Sentry.Bindings.Cocoa.targets

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,17 @@
4949
</ItemGroup>
5050
</Target>
5151

52+
<!--
53+
Ensure the AppDomain.CurrentDomain.UnhandledException gets triggered - see:
54+
https://github.com/xamarin/xamarin-macios/issues/15252
55+
Not supported on the CoreCLR - see:
56+
https://github.com/xamarin/xamarin-macios/blob/0a81da28e4217624a54ccb83541e1eb8ba651fca/runtime/runtime.m#L2480-L2491
57+
58+
The condition is a bit hacky - it relies on:
59+
https://github.com/xamarin/xamarin-macios/blob/0ab074390689880fe9269804a0156341d30251f6/dotnet/targets/Xamarin.Shared.Sdk.targets#L1004-L1006
60+
-->
61+
<PropertyGroup Condition="'$(_XamarinRuntime)' != 'CoreCLR'">
62+
<MtouchExtraArgs>--marshal-managed-exceptions=unwindnativecode</MtouchExtraArgs>
63+
</PropertyGroup>
64+
5265
</Project>

src/Sentry/Platforms/Cocoa/SentrySdk.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using Sentry.Cocoa;
22
using Sentry.Cocoa.Extensions;
33
using Sentry.Extensibility;
4+
using Sentry.Internal;
5+
using Sentry.PlatformAbstractions;
46

57
// ReSharper disable once CheckNamespace
68
namespace Sentry;
@@ -10,10 +12,10 @@ public static partial class SentrySdk
1012
private static void InitSentryCocoaSdk(SentryOptions options)
1113
{
1214
options.LogDebug("Initializing native SDK");
13-
// Workaround for https://github.com/xamarin/xamarin-macios/issues/15252
1415
ObjCRuntime.Runtime.MarshalManagedException += (_, args) =>
1516
{
16-
args.ExceptionMode = ObjCRuntime.MarshalManagedExceptionMode.UnwindNativeCode;
17+
// This MAY be overriden in Sentry.Bindings.Cocoa.targets
18+
options.LogDebug($"MarshalManagedExceptionMode: {args.ExceptionMode}");
1719
};
1820

1921
// Set default release and distribution

0 commit comments

Comments
 (0)