Allow null parent tag when calling `GetTagHelpersGivenParent`.
- A `null` parent tag in all of our other API represents "any" parent tag, or in this case "root". Prior to this change we'd expect the caller to do their own verification of the parent and then assume all `TagHelperDescriptor`s are valid; this isn't sufficient because only our code base should have that knowledge. #1188
This commit is contained in:
parent
af3cf497a6
commit
96d97f65e9
|
|
@ -138,11 +138,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
throw new ArgumentNullException(nameof(documentContext));
|
||||
}
|
||||
|
||||
if (parentTag == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(parentTag));
|
||||
}
|
||||
|
||||
var matchingDescriptors = new List<TagHelperDescriptor>();
|
||||
var descriptors = documentContext?.TagHelpers;
|
||||
if (descriptors?.Count == 0)
|
||||
|
|
|
|||
|
|
@ -286,6 +286,26 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
Assert.Equal(expectedDescriptors, descriptors, TagHelperDescriptorComparer.CaseSensitive);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetTagHelpersGivenParent_AllowsRootParentTag()
|
||||
{
|
||||
// Arrange
|
||||
var documentDescriptors = new[]
|
||||
{
|
||||
ITagHelperDescriptorBuilder.Create("TestType", "TestAssembly")
|
||||
.TagMatchingRule(rule => rule.RequireTagName("div"))
|
||||
.Build()
|
||||
};
|
||||
var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors);
|
||||
var service = new DefaultTagHelperFactsService();
|
||||
|
||||
// Act
|
||||
var descriptors = service.GetTagHelpersGivenParent(documentContext, parentTag: null /* root */);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(documentDescriptors, descriptors, TagHelperDescriptorComparer.CaseSensitive);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetTagHelpersGivenParent_AllowsUnspecifiedParentTagHelpers()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue