From c5bf7cf850a6fbe73170a209c93f34bb1de82db0 Mon Sep 17 00:00:00 2001 From: neo Date: Thu, 11 Jul 2024 23:07:00 +0200 Subject: [PATCH] Comparing a Dictionary with Enum as key the PropertyPath will not result in something like [EnumName].Value.MyProperty instead it will result in Value.MyProperty because ShouldCompareByKeys will return false. Enum is not a simple type even if it is a integer or similar. --- Compare-NET-Objects/TypeComparers/DictionaryComparer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Compare-NET-Objects/TypeComparers/DictionaryComparer.cs b/Compare-NET-Objects/TypeComparers/DictionaryComparer.cs index e045292..ddc247c 100644 --- a/Compare-NET-Objects/TypeComparers/DictionaryComparer.cs +++ b/Compare-NET-Objects/TypeComparers/DictionaryComparer.cs @@ -93,7 +93,7 @@ private static bool ShouldCompareByKeys(CompareParms parms) var enumerator1 = ((IDictionary) parms.Object1).GetEnumerator(); enumerator1.MoveNext(); shouldCompareByKeys = - enumerator1.Key != null && TypeHelper.IsSimpleType(enumerator1.Key.GetType()); + enumerator1.Key != null && (TypeHelper.IsSimpleType(enumerator1.Key.GetType()) || TypeHelper.IsEnum(enumerator1.Key.GetType())); } }