diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/BoundAttributeDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Evolution/BoundAttributeDescriptor.cs index 768a4eddf2..08c1231e0c 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/BoundAttributeDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/BoundAttributeDescriptor.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Generic; using System.Linq; @@ -9,7 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution /// /// A metadata class describing a tag helper attribute. /// - public abstract class BoundAttributeDescriptor + public abstract class BoundAttributeDescriptor : IEquatable { protected BoundAttributeDescriptor(string kind) { @@ -49,5 +50,20 @@ namespace Microsoft.AspNetCore.Razor.Evolution return anyErrors; } } + + public bool Equals(BoundAttributeDescriptor other) + { + return BoundAttributeDescriptorComparer.Default.Equals(this, other); + } + + public override bool Equals(object obj) + { + return Equals(obj as BoundAttributeDescriptor); + } + + public override int GetHashCode() + { + return BoundAttributeDescriptorComparer.Default.GetHashCode(this); + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperDescriptor.cs b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperDescriptor.cs index 0babe18bc2..0f80744780 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperDescriptor.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperDescriptor.cs @@ -1,12 +1,13 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Generic; using System.Linq; namespace Microsoft.AspNetCore.Razor.Evolution { - public abstract class TagHelperDescriptor + public abstract class TagHelperDescriptor : IEquatable { private IEnumerable _allDiagnostics; @@ -60,5 +61,20 @@ namespace Microsoft.AspNetCore.Razor.Evolution return _allDiagnostics; } + + public bool Equals(TagHelperDescriptor other) + { + return TagHelperDescriptorComparer.Default.Equals(this, other); + } + + public override bool Equals(object obj) + { + return Equals(obj as TagHelperDescriptor); + } + + public override int GetHashCode() + { + return TagHelperDescriptorComparer.Default.GetHashCode(this); + } } } diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperDescriptorComparer.cs b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperDescriptorComparer.cs similarity index 99% rename from src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperDescriptorComparer.cs rename to src/Microsoft.AspNetCore.Razor.Evolution/TagHelperDescriptorComparer.cs index 7e429d5dad..44f5e856af 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/TagHelperDescriptorComparer.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/TagHelperDescriptorComparer.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.Internal; -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { internal class TagHelperDescriptorComparer : IEqualityComparer { diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/TagMatchingRule.cs b/src/Microsoft.AspNetCore.Razor.Evolution/TagMatchingRule.cs index 3de80d4e2c..7e1c4eeaed 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/TagMatchingRule.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/TagMatchingRule.cs @@ -1,12 +1,13 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Generic; using System.Linq; namespace Microsoft.AspNetCore.Razor.Evolution { - public abstract class TagMatchingRule + public abstract class TagMatchingRule : IEquatable { private IEnumerable _allDiagnostics; @@ -42,5 +43,20 @@ namespace Microsoft.AspNetCore.Razor.Evolution return _allDiagnostics; } + + public bool Equals(TagMatchingRule other) + { + return TagMatchingRuleComparer.Default.Equals(this, other); + } + + public override bool Equals(object obj) + { + return Equals(obj as TagMatchingRule); + } + + public override int GetHashCode() + { + return TagMatchingRuleComparer.Default.GetHashCode(this); + } } }