Change `GetHashCode()` for `CaseSensitiveTagHelperDescriptorComparer` to order values.

- Ordered `RequiredAttributes`, `AllowedChildren` and `Attributes`.

#489
This commit is contained in:
N. Taylor Mullen 2015-08-21 15:20:57 -07:00
parent 55760b4fcb
commit dbcc5e240a
1 changed files with 7 additions and 4 deletions

View File

@ -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;