Fix inherited TagHelper properties.
- Used to only look at declared properties on the tag helper type, now we get the runtime properties. - Fixed Runtime test projec to work with new CLR changes (looks like it was missed). #189
This commit is contained in:
parent
7364c6f6db
commit
4f9a6fed93
|
|
@ -62,8 +62,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
|||
|
||||
private static IEnumerable<TagHelperAttributeDescriptor> GetAttributeDescriptors(Type type)
|
||||
{
|
||||
var typeInfo = type.GetTypeInfo();
|
||||
var properties = typeInfo.DeclaredProperties.Where(IsValidProperty);
|
||||
var properties = type.GetRuntimeProperties().Where(IsValidProperty);
|
||||
var attributeDescriptors = properties.Select(ToAttributeDescriptor);
|
||||
|
||||
return attributeDescriptors;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,28 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
|||
Assert.Equal(descriptor, expectedDescriptor, CompleteTagHelperDescriptorComparer.Default);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreateDescriptor_BuildsDescriptorsWithInheritedProperties()
|
||||
{
|
||||
// Arrange
|
||||
var intProperty = typeof(InheritedSingleAttributeTagHelper).GetProperty(
|
||||
nameof(InheritedSingleAttributeTagHelper.IntAttribute));
|
||||
var expectedDescriptor = new TagHelperDescriptor(
|
||||
"InheritedSingleAttribute",
|
||||
typeof(InheritedSingleAttributeTagHelper).FullName,
|
||||
ContentBehavior.None,
|
||||
new[] {
|
||||
new TagHelperAttributeDescriptor(nameof(InheritedSingleAttributeTagHelper.IntAttribute), intProperty)
|
||||
});
|
||||
|
||||
// Act
|
||||
var descriptors = TagHelperDescriptorFactory.CreateDescriptors(typeof(InheritedSingleAttributeTagHelper));
|
||||
|
||||
// Assert
|
||||
var descriptor = Assert.Single(descriptors);
|
||||
Assert.Equal(descriptor, expectedDescriptor, CompleteTagHelperDescriptorComparer.Default);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreateDescriptor_BuildsDescriptorsWithConventionNames()
|
||||
{
|
||||
|
|
@ -257,5 +279,9 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
|||
private class MultipleAttributeTagHelper
|
||||
{
|
||||
}
|
||||
|
||||
private class InheritedSingleAttributeTagHelper : SingleAttributeTagHelper
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,6 @@
|
|||
"test": "Xunit.KRunner"
|
||||
},
|
||||
"frameworks": {
|
||||
"net45": { }
|
||||
"aspnet50": { }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue