From 18b07abb449415fe07a7f5aa2f86ece1afb5af71 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Thu, 7 Jun 2018 14:59:31 -0400 Subject: [PATCH] refactor: Resolving code smells --- ICD.Common.Utils/SafeMutex.cs | 1 + ICD.Common.Utils/StringUtils.cs | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ICD.Common.Utils/SafeMutex.cs b/ICD.Common.Utils/SafeMutex.cs index c2d3bb2..66c2798 100644 --- a/ICD.Common.Utils/SafeMutex.cs +++ b/ICD.Common.Utils/SafeMutex.cs @@ -66,6 +66,7 @@ namespace ICD.Common.Utils } catch (ObjectDisposedException) { + // Releasing a disposed mutex in this case is valid behaviour } } diff --git a/ICD.Common.Utils/StringUtils.cs b/ICD.Common.Utils/StringUtils.cs index ce73daa..f08e271 100644 --- a/ICD.Common.Utils/StringUtils.cs +++ b/ICD.Common.Utils/StringUtils.cs @@ -277,21 +277,20 @@ namespace ICD.Common.Utils throw new ArgumentNullException("convertFunc"); result = default(T); - bool retVal = false; - + try { result = convertFunc(value); - retVal = true; + return true; } catch (FormatException) { + return false; } catch (InvalidCastException) { + return false; } - - return retVal; } ///