From 5f2c5e6dcbb2b4cc7d48075743f04a5fb93519c8 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Tue, 15 Jun 2021 14:13:37 -0400 Subject: [PATCH] fix: Fixed a bug where EnumUtils.GetFlags, and overloads, would also return defined composites --- ICD.Common.Utils/EnumUtils.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ICD.Common.Utils/EnumUtils.cs b/ICD.Common.Utils/EnumUtils.cs index e01c450..9de5d1e 100644 --- a/ICD.Common.Utils/EnumUtils.cs +++ b/ICD.Common.Utils/EnumUtils.cs @@ -352,10 +352,11 @@ namespace ICD.Common.Utils /// public static IEnumerable GetFlags(Type type, object value) { - return s_EnumFlagsCacheSection.Execute(() => s_EnumFlagsCache.GetOrAddNew(type, () => new Dictionary()) - .GetOrAddNew(value, () => GetValues(type) - .Where(f => HasFlag(value, f)) - .ToArray())); + return s_EnumFlagsCacheSection.Execute(() => s_EnumFlagsCache + .GetOrAddNew(type, () => new Dictionary()) + .GetOrAddNew(value, () => GetValues(type) + .Where(f => !HasMultipleFlags((int)f) && HasFlag(value, f)) + .ToArray())); } ///