diff --git a/src/Microsoft.AspNet.Razor/TagHelpers/TypeBasedTagHelperDescriptorComparer.cs b/src/Microsoft.AspNet.Razor/TagHelpers/TypeBasedTagHelperDescriptorComparer.cs index 2e3356ab17..bd0efdc0fa 100644 --- a/src/Microsoft.AspNet.Razor/TagHelpers/TypeBasedTagHelperDescriptorComparer.cs +++ b/src/Microsoft.AspNet.Razor/TagHelpers/TypeBasedTagHelperDescriptorComparer.cs @@ -42,7 +42,8 @@ namespace Microsoft.AspNet.Razor.TagHelpers return true; } - return string.Equals(descriptorX.AssemblyName, descriptorY.AssemblyName, StringComparison.Ordinal) && + return descriptorX != null && + string.Equals(descriptorX.AssemblyName, descriptorY.AssemblyName, StringComparison.Ordinal) && string.Equals(descriptorX.TypeName, descriptorY.TypeName, StringComparison.Ordinal); } diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/CaseSensitiveTagHelperAttributeComparer.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/CaseSensitiveTagHelperAttributeComparer.cs index 7625c9fe89..a5ba8e300d 100644 --- a/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/CaseSensitiveTagHelperAttributeComparer.cs +++ b/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/CaseSensitiveTagHelperAttributeComparer.cs @@ -18,9 +18,13 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers public bool Equals(IReadOnlyTagHelperAttribute attributeX, IReadOnlyTagHelperAttribute attributeY) { - return - attributeX == attributeY || - // Normal comparer doesn't care about the Name case, in tests we do. + if (attributeX == attributeY) + { + return true; + } + + // Normal comparer (TagHelperAttribute.Equals()) doesn't care about the Name case, in tests we do. + return attributeX != null && string.Equals(attributeX.Name, attributeY.Name, StringComparison.Ordinal) && Equals(attributeX.Value, attributeY.Value); }