From dbcc5e240aff3dfb7674d0f139dd60e903f0d453 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 21 Aug 2015 15:20:57 -0700 Subject: [PATCH] Change `GetHashCode()` for `CaseSensitiveTagHelperDescriptorComparer` to order values. - Ordered `RequiredAttributes`, `AllowedChildren` and `Attributes`. #489 --- .../CaseSensitiveTagHelperDescriptorComparer.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNet.Razor.Test.Sources/CaseSensitiveTagHelperDescriptorComparer.cs b/src/Microsoft.AspNet.Razor.Test.Sources/CaseSensitiveTagHelperDescriptorComparer.cs index 2d262ce832..11593e545c 100644 --- a/src/Microsoft.AspNet.Razor.Test.Sources/CaseSensitiveTagHelperDescriptorComparer.cs +++ b/src/Microsoft.AspNet.Razor.Test.Sources/CaseSensitiveTagHelperDescriptorComparer.cs @@ -60,22 +60,25 @@ namespace Microsoft.AspNet.Razor.Test.Internal TagHelperDesignTimeDescriptorComparer.Default.GetHashCode(descriptor.DesignTimeDescriptor)); } - foreach (var requiredAttribute in descriptor.RequiredAttributes) + foreach (var requiredAttribute in descriptor.RequiredAttributes.OrderBy(attribute => attribute)) { hashCodeCombiner.Add(requiredAttribute, StringComparer.Ordinal); } if (descriptor.AllowedChildren != null) { - foreach (var child in descriptor.AllowedChildren) + foreach (var child in descriptor.AllowedChildren.OrderBy(child => child)) { hashCodeCombiner.Add(child, StringComparer.Ordinal); } } - foreach (var attribute in descriptor.Attributes) + var orderedAttributeHashCodes = descriptor.Attributes + .Select(attribute => TagHelperAttributeDescriptorComparer.Default.GetHashCode(attribute)) + .OrderBy(hashcode => hashcode); + foreach (var attributeHashCode in orderedAttributeHashCodes) { - hashCodeCombiner.Add(TagHelperAttributeDescriptorComparer.Default.GetHashCode(attribute)); + hashCodeCombiner.Add(attributeHashCode); } return hashCodeCombiner.CombinedHash;