diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/TagHelperBlockRewriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/TagHelperBlockRewriter.cs index fefcf4aeee..23a0a488a1 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/TagHelperBlockRewriter.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/TagHelperBlockRewriter.cs @@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy foreach (var descriptor in bindingResult.Descriptors) { - var boundRules = bindingResult.GetBoundRules(descriptor); + var boundRules = bindingResult.Mappings[descriptor]; var nonDefaultRule = boundRules.FirstOrDefault(rule => rule.TagStructure != TagStructure.Unspecified); if (nonDefaultRule?.TagStructure == TagStructure.WithoutEndTag) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/TagHelperParseTreeRewriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/TagHelperParseTreeRewriter.cs index 47f96d7d3b..1619f42240 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/TagHelperParseTreeRewriter.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/TagHelperParseTreeRewriter.cs @@ -336,7 +336,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy foreach (var descriptor in tagHelperBinding.Descriptors) { - var boundRules = tagHelperBinding.GetBoundRules(descriptor); + var boundRules = tagHelperBinding.Mappings[descriptor]; var invalidRule = boundRules.FirstOrDefault(rule => rule.TagStructure == TagStructure.WithoutEndTag); if (invalidRule != null) @@ -456,7 +456,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy TagStructure? baseStructure = null; foreach (var descriptor in bindingResult.Descriptors) { - var boundRules = bindingResult.GetBoundRules(descriptor); + var boundRules = bindingResult.Mappings[descriptor]; foreach (var rule in boundRules) { if (rule.TagStructure != TagStructure.Unspecified) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperBinding.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperBinding.cs index a5590c536e..4b88cf5b12 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperBinding.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/TagHelperBinding.cs @@ -1,14 +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; namespace Microsoft.AspNetCore.Razor.Language { public sealed class TagHelperBinding { - private IReadOnlyDictionary> _mappings; - internal TagHelperBinding( string tagName, IReadOnlyList> attributes, @@ -19,12 +18,42 @@ namespace Microsoft.AspNetCore.Razor.Language TagName = tagName; Attributes = attributes; ParentTagName = parentTagName; + Mappings = mappings; TagHelperPrefix = tagHelperPrefix; - _mappings = mappings; } - public IEnumerable Descriptors => _mappings.Keys; + public IEnumerable Descriptors => Mappings.Keys; + + /// + /// Gets a value that indicates whether the the binding matched on attributes only. + /// + /// false if the entire element should be classified as a tag helper. + /// + /// If this returns true, use TagHelperFactsService.GetBoundTagHelperAttributes to find the + /// set of attributes that should be considered part of the match. + /// + public bool IsAttributeMatch + { + get + { + foreach (var descriptor in Mappings.Keys) + { + if (!descriptor.Metadata.TryGetValue(TagHelperMetadata.Common.ClassifyAttributesOnly, out var value) || + !string.Equals(value, bool.TrueString, StringComparison.OrdinalIgnoreCase)) + { + return false; + } + } + + // All the matching tag helpers want to be classified with **attributes only**. + // + // Ex: (components) + // + //