Change TagHelperAttributeDescriptor to not depend on PropertyInfo.
- Right now the only information that is used from the PropertyInfo is the PropertyName and the PropertyType, therefore changed the PropertyInfo property on TagHelperAttributeDescriptor to be AttributeTypeName since we already had an accessor for AttributePropertyName. - Modified test comparers to validate type names. #214
This commit is contained in:
parent
2200f7dc3a
commit
829faaaa4b
|
|
@ -497,7 +497,7 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
|
|||
|
||||
private static bool IsStringAttribute(TagHelperAttributeDescriptor attributeDescriptor)
|
||||
{
|
||||
return attributeDescriptor.PropertyInfo.PropertyType == typeof(string);
|
||||
return attributeDescriptor.AttributeTypeName == typeof(string).FullName;
|
||||
}
|
||||
|
||||
private static bool TryGetPlainTextValue(Chunk chunk, out string plainText)
|
||||
|
|
|
|||
|
|
@ -16,11 +16,27 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
|||
/// <param name="attributeName">The HTML attribute name.</param>
|
||||
/// <param name="propertyInfo">The <see cref="System.Reflection.PropertyInfo"/> for the tag
|
||||
/// helper attribute</param>
|
||||
public TagHelperAttributeDescriptor(string attributeName, PropertyInfo propertyInfo)
|
||||
: this(attributeName, propertyInfo.Name, propertyInfo.PropertyType.FullName)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates a new <see cref="TagHelperAttributeDescriptor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="attributeName">The HTML attribute name.</param>
|
||||
/// <param name="attributePropertyName">The name of the CLR property name that corresponds to the HTML
|
||||
/// attribute name.</param>
|
||||
/// <param name="attributeTypeName">
|
||||
/// The full name of the <see cref="System.Type"/> that corresponds to the HTML attribute.
|
||||
/// </param>
|
||||
public TagHelperAttributeDescriptor(string attributeName,
|
||||
PropertyInfo propertyInfo)
|
||||
string attributePropertyName,
|
||||
string attributeTypeName)
|
||||
{
|
||||
AttributeName = attributeName;
|
||||
PropertyInfo = propertyInfo;
|
||||
AttributePropertyName = attributePropertyName;
|
||||
AttributeTypeName = attributeTypeName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -31,17 +47,11 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
|||
/// <summary>
|
||||
/// The name of the CLR property name that corresponds to the HTML attribute name.
|
||||
/// </summary>
|
||||
public string AttributePropertyName
|
||||
{
|
||||
get
|
||||
{
|
||||
return PropertyInfo.Name;
|
||||
}
|
||||
}
|
||||
public string AttributePropertyName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="System.Reflection.PropertyInfo"/> for the tag helper attribute
|
||||
/// The full name of the <see cref="System.Type"/> that corresponds to the HTML attribute.
|
||||
/// </summary>
|
||||
public PropertyInfo PropertyInfo { get; private set; }
|
||||
public string AttributeTypeName { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -44,7 +44,8 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
|||
public bool Equals(TagHelperAttributeDescriptor descriptorX, TagHelperAttributeDescriptor descriptorY)
|
||||
{
|
||||
return descriptorX.AttributeName == descriptorY.AttributeName &&
|
||||
descriptorX.AttributePropertyName == descriptorY.AttributePropertyName;
|
||||
descriptorX.AttributePropertyName == descriptorY.AttributePropertyName &&
|
||||
descriptorX.AttributeTypeName == descriptorY.AttributeTypeName;
|
||||
}
|
||||
|
||||
public int GetHashCode(TagHelperAttributeDescriptor descriptor)
|
||||
|
|
@ -52,6 +53,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
|||
return HashCodeCombiner.Start()
|
||||
.Add(descriptor.AttributeName)
|
||||
.Add(descriptor.AttributePropertyName)
|
||||
.Add(descriptor.AttributeTypeName)
|
||||
.CombinedHash;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue