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

[tools/runtime] Enable exception marshalling by default for all platforms in .NET. #14051

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -2216,7 +2216,11 @@ -(void) xamarinSetFlags: (enum XamarinGCHandleFlags) flags;
}

if (mode == MarshalObjectiveCExceptionModeDefault)
#if DOTNET
mode = MarshalObjectiveCExceptionModeThrowManagedException;
#else
mode = xamarin_is_gc_coop ? MarshalObjectiveCExceptionModeThrowManagedException : MarshalObjectiveCExceptionModeUnwindManagedCode;
#endif

xamarin_log_objectivec_exception (ns_exception, mode);

Expand Down Expand Up @@ -2286,7 +2290,7 @@ -(void) xamarinSetFlags: (enum XamarinGCHandleFlags) flags;
}

if (mode == MarshalManagedExceptionModeDefault) {
#if defined (CORECLR_RUNTIME)
#if DOTNET
mode = MarshalManagedExceptionModeThrowObjectiveCException;
#else
mode = xamarin_is_gc_coop ? MarshalManagedExceptionModeThrowObjectiveCException : MarshalManagedExceptionModeUnwindNativeCode;
Expand Down
5 changes: 4 additions & 1 deletion tests/monotouch-test/ObjCRuntime/ExceptionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ namespace MonoTouchFixtures.ObjCRuntime {
[Preserve (AllMembers = true)]
public class ExceptionsTest {

#if __WATCHOS__
#if NET
MarshalObjectiveCExceptionMode defaultObjectiveCExceptionMode = MarshalObjectiveCExceptionMode.ThrowManagedException;
MarshalManagedExceptionMode defaultManagedExceptionMode = MarshalManagedExceptionMode.Default;
#elif __WATCHOS__
MarshalObjectiveCExceptionMode defaultObjectiveCExceptionMode = MarshalObjectiveCExceptionMode.ThrowManagedException;
MarshalManagedExceptionMode defaultManagedExceptionMode = MarshalManagedExceptionMode.Default;
#else
Expand Down
4 changes: 2 additions & 2 deletions tools/common/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ public void SetManagedExceptionMode ()
{
switch (MarshalManagedExceptions) {
case MarshalManagedExceptionMode.Default:
if (XamarinRuntime == XamarinRuntime.CoreCLR) {
if (Driver.IsDotNet) {
MarshalManagedExceptions = MarshalManagedExceptionMode.ThrowObjectiveCException;
} else if (EnableCoopGC.Value) {
MarshalManagedExceptions = MarshalManagedExceptionMode.ThrowObjectiveCException;
Expand Down Expand Up @@ -1394,7 +1394,7 @@ public void SetObjectiveCExceptionMode ()
{
switch (MarshalObjectiveCExceptions) {
case MarshalObjectiveCExceptionMode.Default:
if (XamarinRuntime == XamarinRuntime.CoreCLR) {
if (Driver.IsDotNet) {
MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.ThrowManagedException;
} else if (EnableCoopGC.Value) {
MarshalObjectiveCExceptions = MarshalObjectiveCExceptionMode.ThrowManagedException;
Expand Down