From 294fb5c3cd4093de811f2f140e7e42a728573307 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Mon, 11 May 2015 22:12:28 -0700 Subject: [PATCH] Quick fix: Missed `null` checks in 7dc0508 --- .../TagHelpers/TypeBasedTagHelperDescriptorComparer.cs | 3 ++- .../CaseSensitiveTagHelperAttributeComparer.cs | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) 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); }