From 9915f93a3a0240ca44d0651811e894f50038f02e Mon Sep 17 00:00:00 2001 From: Bugsnag Platforms Team Date: Wed, 13 May 2020 16:39:38 +0100 Subject: [PATCH] Conditional compilation logic simplified --- src/Bugsnag/UnhandledException.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Bugsnag/UnhandledException.cs b/src/Bugsnag/UnhandledException.cs index 947eab4..d884f29 100644 --- a/src/Bugsnag/UnhandledException.cs +++ b/src/Bugsnag/UnhandledException.cs @@ -11,15 +11,11 @@ class UnhandledException private readonly object _currentClientLock = new object(); private IClient _currentClient; -#if !(NET35 || NET40) private bool _unobservedTerminates; -#endif private UnhandledException() { -#if !(NET35 || NET40) _unobservedTerminates = DetermineUnobservedTerminates(); -#endif AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; @@ -59,7 +55,9 @@ public void ConfigureClient(IClient client, IConfiguration configuration) /// private bool DetermineUnobservedTerminates() { -#if NET45 +#if NET35 || NET40 + return true; +#elif NET45 System.Xml.Linq.XElement configFile = System.Xml.Linq.XElement.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); var configValue = configFile?.Element("runtime")?.Element("ThrowUnobservedTaskExceptions")?.Attribute("enabled")?.Value; bool value; @@ -77,11 +75,7 @@ private void CurrentDomain_ProcessExit(object sender, EventArgs e) private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { -#if NET35 || NET40 - HandleEvent(e.Exception as Exception, !e.Observed); -#else - HandleEvent(e.Exception as Exception, _unobservedTerminates); -#endif + HandleEvent(e.Exception as Exception, _unobservedTerminates && !e.Observed); } [HandleProcessCorruptedStateExceptions]