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)
|
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)
|
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="attributeName">The HTML attribute name.</param>
|
||||||
/// <param name="propertyInfo">The <see cref="System.Reflection.PropertyInfo"/> for the tag
|
/// <param name="propertyInfo">The <see cref="System.Reflection.PropertyInfo"/> for the tag
|
||||||
/// helper attribute</param>
|
/// 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,
|
public TagHelperAttributeDescriptor(string attributeName,
|
||||||
PropertyInfo propertyInfo)
|
string attributePropertyName,
|
||||||
|
string attributeTypeName)
|
||||||
{
|
{
|
||||||
AttributeName = attributeName;
|
AttributeName = attributeName;
|
||||||
PropertyInfo = propertyInfo;
|
AttributePropertyName = attributePropertyName;
|
||||||
|
AttributeTypeName = attributeTypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -31,17 +47,11 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name of the CLR property name that corresponds to the HTML attribute name.
|
/// The name of the CLR property name that corresponds to the HTML attribute name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AttributePropertyName
|
public string AttributePropertyName { get; private set; }
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return PropertyInfo.Name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </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)
|
public bool Equals(TagHelperAttributeDescriptor descriptorX, TagHelperAttributeDescriptor descriptorY)
|
||||||
{
|
{
|
||||||
return descriptorX.AttributeName == descriptorY.AttributeName &&
|
return descriptorX.AttributeName == descriptorY.AttributeName &&
|
||||||
descriptorX.AttributePropertyName == descriptorY.AttributePropertyName;
|
descriptorX.AttributePropertyName == descriptorY.AttributePropertyName &&
|
||||||
|
descriptorX.AttributeTypeName == descriptorY.AttributeTypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetHashCode(TagHelperAttributeDescriptor descriptor)
|
public int GetHashCode(TagHelperAttributeDescriptor descriptor)
|
||||||
|
|
@ -52,6 +53,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
|
||||||
return HashCodeCombiner.Start()
|
return HashCodeCombiner.Start()
|
||||||
.Add(descriptor.AttributeName)
|
.Add(descriptor.AttributeName)
|
||||||
.Add(descriptor.AttributePropertyName)
|
.Add(descriptor.AttributePropertyName)
|
||||||
|
.Add(descriptor.AttributeTypeName)
|
||||||
.CombinedHash;
|
.CombinedHash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue