|
5 | 5 | using System.Collections.Generic;
|
6 | 6 | using System.Linq;
|
7 | 7 | using Microsoft.AspNetCore.Razor.Language;
|
| 8 | +using Microsoft.AspNetCore.Razor.Language.Components; |
8 | 9 | using Microsoft.CodeAnalysis.Razor;
|
9 | 10 | using Xunit;
|
10 | 11 |
|
@@ -597,6 +598,42 @@ public void GetAttributeCompletions_NoDescriptorsForTagReturnsExistingCompletion
|
597 | 598 | AssertCompletionsAreEquivalent(expectedCompletions, completions);
|
598 | 599 | }
|
599 | 600 |
|
| 601 | + [Fact] |
| 602 | + public void GetElementCompletions_IgnoresDirectiveAttributes() |
| 603 | + { |
| 604 | + // Arrange |
| 605 | + var documentDescriptors = new[] |
| 606 | + { |
| 607 | + TagHelperDescriptorBuilder.Create("BindAttribute", "TestAssembly") |
| 608 | + .TagMatchingRuleDescriptor(rule => rule.RequireTagName("input")) |
| 609 | + .BoundAttributeDescriptor(builder => |
| 610 | + { |
| 611 | + builder.Name = "@bind"; |
| 612 | + builder.AddMetadata(ComponentMetadata.Common.DirectiveAttribute, bool.TrueString); |
| 613 | + }) |
| 614 | + .TagOutputHint("table") |
| 615 | + .Build(), |
| 616 | + }; |
| 617 | + var expectedCompletions = ElementCompletionResult.Create(new Dictionary<string, HashSet<TagHelperDescriptor>>() |
| 618 | + { |
| 619 | + ["table"] = new HashSet<TagHelperDescriptor>(), |
| 620 | + }); |
| 621 | + |
| 622 | + var existingCompletions = new[] { "table" }; |
| 623 | + var completionContext = BuildElementCompletionContext( |
| 624 | + documentDescriptors, |
| 625 | + existingCompletions, |
| 626 | + containingTagName: "body", |
| 627 | + containingParentTagName: null); |
| 628 | + var service = CreateTagHelperCompletionFactsService(); |
| 629 | + |
| 630 | + // Act |
| 631 | + var completions = service.GetElementCompletions(completionContext); |
| 632 | + |
| 633 | + // Assert |
| 634 | + AssertCompletionsAreEquivalent(expectedCompletions, completions); |
| 635 | + } |
| 636 | + |
600 | 637 | [Fact]
|
601 | 638 | public void GetElementCompletions_TagOutputHintDoesNotFallThroughToSchemaCheck()
|
602 | 639 | {
|
|
0 commit comments