From 2c0e9faa32e6167138a2efbf498d7f79a29a2a3c Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Fri, 23 Dec 2022 22:36:19 +0200 Subject: [PATCH] Remove throwing exceptions from invoked methods with debugger The same effect can be achieved by enabling all CLR exceptions in VS debugger settings, and it also supports continuation after catching exceptions. --- Source/Engine/Engine/NativeInterop.cs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/Source/Engine/Engine/NativeInterop.cs b/Source/Engine/Engine/NativeInterop.cs index 22ec90f98..b2d30875f 100644 --- a/Source/Engine/Engine/NativeInterop.cs +++ b/Source/Engine/Engine/NativeInterop.cs @@ -827,11 +827,6 @@ namespace FlaxEngine /// internal unsafe static partial class NativeInterop { - /// - /// Enables first-chance exception handling in invoked methods while debugger is attached. - /// - public static bool CatchExceptions = true; - internal static Dictionary AssemblyLocations = new Dictionary(); private static bool firstAssemblyLoaded = false; @@ -2024,9 +2019,6 @@ namespace FlaxEngine } catch (Exception exception) { - if (Debugger.IsAttached && CatchExceptions) - throw; - Marshal.WriteIntPtr(exceptionPtr, GCHandle.ToIntPtr(GCHandle.Alloc(exception, GCHandleType.Weak))); return IntPtr.Zero; } @@ -2052,9 +2044,6 @@ namespace FlaxEngine } catch (Exception exception) { - if (Debugger.IsAttached && CatchExceptions) - throw; - // The internal exception thrown in MethodInfo.Invoke is caught here Exception realException = exception; if (exception.InnerException != null && exception.TargetSite.ReflectedType.Name == "MethodInvoker") @@ -2637,9 +2626,6 @@ namespace FlaxEngine } catch (Exception exception) { - if (Debugger.IsAttached && CatchExceptions) - throw; - // Returned exception is the last parameter IntPtr exceptionPtr = nativePtrs[parameterTypes.Length]; Marshal.WriteIntPtr(exceptionPtr, GCHandle.ToIntPtr(GCHandle.Alloc(exception, GCHandleType.Weak))); @@ -2662,9 +2648,6 @@ namespace FlaxEngine } catch (Exception exception) { - if (Debugger.IsAttached && CatchExceptions) - throw; - // Returned exception is the last parameter IntPtr exceptionPtr = nativePtrs[numParams]; Marshal.WriteIntPtr(exceptionPtr, GCHandle.ToIntPtr(GCHandle.Alloc(exception, GCHandleType.Weak)));