diff --git a/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/IMemberInfo.cs b/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/IMemberInfo.cs
deleted file mode 100644
index 6d569b0df1..0000000000
--- a/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/IMemberInfo.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-
-namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
-{
- ///
- /// Metadata common to types and properties.
- ///
- public interface IMemberInfo
- {
- ///
- /// Gets the name.
- ///
- string Name { get; }
-
- ///
- /// Retrieves a collection of custom s of type applied
- /// to this instance of .
- ///
- /// The type of to search for.
- /// A sequence of custom s of type
- /// .
- /// Result not include inherited s.
- IEnumerable GetCustomAttributes()
- where TAttribute : Attribute;
- }
-}
diff --git a/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/IPropertyInfo.cs b/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/IPropertyInfo.cs
deleted file mode 100644
index beb0840b57..0000000000
--- a/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/IPropertyInfo.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
-{
- ///
- /// Contains property metadata.
- ///
- public interface IPropertyInfo : IMemberInfo
- {
- ///
- /// Gets a value indicating whether this property has a public getter.
- ///
- bool HasPublicGetter { get; }
-
- ///
- /// Gets a value indicating whether this property has a public setter.
- ///
- bool HasPublicSetter { get; }
-
- ///
- /// Gets the of the property.
- ///
- ITypeInfo PropertyType { get; }
- }
-}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/ITypeInfo.cs b/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/ITypeInfo.cs
deleted file mode 100644
index dd2ded0af5..0000000000
--- a/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/ITypeInfo.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-
-namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
-{
- ///
- /// Contains type metadata.
- ///
- public interface ITypeInfo : IMemberInfo, IEquatable
- {
- ///
- /// Fully qualified name of the type.
- ///
- ///
- /// On CoreCLR, some BCL types get type forwarded to the full desktop framework implementations at
- /// runtime. For e.g. we compile against System.String in System.Runtime which is type forwarded to
- /// mscorlib at runtime. Consequently for generic types where the includes the assembly
- /// qualified name of generic parameters, FullNames would not match.
- /// Use to compare s instead.
- ///
- string FullName { get; }
-
- ///
- /// Gets s for all properties of the current type excluding indexers.
- ///
- ///
- /// Indexers in this context refer to the CLR notion of an indexer (this [string name]
- /// and does not overlap with the semantics of
- /// .
- ///
- IEnumerable Properties { get; }
-
- ///
- /// Gets a value indicating whether the type is an .
- ///
- bool IsEnum { get; }
-
- ///
- /// Gets a value indicating whether the type is public.
- ///
- bool IsPublic { get; }
-
- ///
- /// Gets a value indicating whether the type is abstract or an interface.
- ///
- bool IsAbstract { get; }
-
- ///
- /// Gets a value indicating whether the type is generic.
- ///
- bool IsGenericType { get; }
-
- ///
- /// Gets a value indicating whether the type implements the interface.
- ///
- bool ImplementsInterface(ITypeInfo interfaceTypeInfo);
-
- ///
- /// Gets the for the TKey and TValue parameters of
- /// .
- ///
- ///
- /// The of TKey and TValue
- /// parameters if the type implements , otherwise null.
- ///
- ///
- /// For open generic types, for generic type parameters is null.
- ///
- ITypeInfo[] GetGenericDictionaryParameters();
- }
-}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/RuntimePropertyInfo.cs b/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/RuntimePropertyInfo.cs
deleted file mode 100644
index 03c4d51751..0000000000
--- a/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/RuntimePropertyInfo.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-
-namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
-{
- ///
- /// adapter for instances.
- ///
- public class RuntimePropertyInfo : IPropertyInfo
- {
- ///
- /// Initializes a new instance of .
- ///
- /// The instance to adapt.
- public RuntimePropertyInfo(PropertyInfo propertyInfo)
- {
- if (propertyInfo == null)
- {
- throw new ArgumentNullException(nameof(propertyInfo));
- }
-
- Property = propertyInfo;
- }
-
- ///
- /// The instance.
- ///
- public PropertyInfo Property { get; }
-
- ///
- public bool HasPublicGetter => Property.GetMethod != null && Property.GetMethod.IsPublic;
-
- ///
- public bool HasPublicSetter => Property.SetMethod != null && Property.SetMethod.IsPublic;
-
- ///
- public string Name => Property.Name;
-
- ///
- public ITypeInfo PropertyType => new RuntimeTypeInfo(Property.PropertyType.GetTypeInfo());
-
- ///
- public IEnumerable GetCustomAttributes() where TAttribute : Attribute
- => Property.GetCustomAttributes(inherit: false);
-
- ///
- public override string ToString() =>
- Property.ToString();
- }
-}
diff --git a/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/RuntimeTypeInfo.cs b/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/RuntimeTypeInfo.cs
deleted file mode 100644
index b05f2cbcd1..0000000000
--- a/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/RuntimeTypeInfo.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Text.RegularExpressions;
-using Microsoft.AspNet.Razor.TagHelpers;
-using Microsoft.Extensions.Internal;
-
-namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
-{
- ///
- /// adapter for instances.
- ///
- public class RuntimeTypeInfo : ITypeInfo
- {
- private static readonly Regex _fullNameSanitizer = new Regex(
- @", [A-Za-z\.]+, Version=\d+\.\d+\.\d+\.\d+, Culture=neutral, PublicKeyToken=\w+",
- RegexOptions.ExplicitCapture,
- Constants.RegexMatchTimeout);
-
- private static readonly TypeInfo TagHelperTypeInfo = typeof(ITagHelper).GetTypeInfo();
- private IEnumerable _properties;
- private string _sanitizedFullName;
-
- ///
- /// Initializes a new instance of
- ///
- /// The instance to adapt.
- public RuntimeTypeInfo(TypeInfo typeInfo)
- {
- if (typeInfo == null)
- {
- throw new ArgumentNullException(nameof(typeInfo));
- }
-
- TypeInfo = typeInfo;
- }
-
- ///
- /// The instance.
- ///
- public TypeInfo TypeInfo { get; }
-
- ///
- public string Name => TypeInfo.Name;
-
- ///
- public string FullName => TypeInfo.FullName;
-
- ///
- public bool IsEnum => TypeInfo.IsEnum;
-
- ///
- public bool IsAbstract => TypeInfo.IsAbstract;
-
- ///
- public bool IsGenericType => TypeInfo.IsGenericType;
-
- ///
- public bool IsPublic => TypeInfo.IsPublic;
-
- ///
- public IEnumerable Properties
- {
- get
- {
- if (_properties == null)
- {
- _properties = TypeInfo
- .AsType()
- .GetRuntimeProperties()
- .Where(property => property.GetIndexParameters().Length == 0)
- .Select(property => new RuntimePropertyInfo(property));
- }
-
- return _properties;
- }
- }
-
- ///
- public bool ImplementsInterface(ITypeInfo interfaceTypeInfo)
- {
- if (interfaceTypeInfo == null)
- {
- throw new ArgumentNullException(nameof(interfaceTypeInfo));
- }
-
- var runtimeTypeInfo = interfaceTypeInfo as RuntimeTypeInfo;
- if (runtimeTypeInfo == null)
- {
- throw new ArgumentException(
- Resources.FormatArgumentMustBeAnInstanceOf(typeof(RuntimeTypeInfo).FullName),
- nameof(interfaceTypeInfo));
- }
-
- return runtimeTypeInfo.TypeInfo.IsInterface && runtimeTypeInfo.TypeInfo.IsAssignableFrom(TypeInfo);
- }
-
- private string SanitizedFullName
- {
- get
- {
- if (_sanitizedFullName == null)
- {
- _sanitizedFullName = SanitizeFullName(FullName);
- }
-
- return _sanitizedFullName;
- }
- }
-
- ///
- public IEnumerable GetCustomAttributes() where TAttribute : Attribute =>
- TypeInfo.GetCustomAttributes(inherit: false);
-
- ///
- public ITypeInfo[] GetGenericDictionaryParameters()
- {
- return ClosedGenericMatcher.ExtractGenericInterface(
- TypeInfo.AsType(),
- typeof(IDictionary<,>))
- ?.GenericTypeArguments
- .Select(type => type.IsGenericParameter ? null : new RuntimeTypeInfo(type.GetTypeInfo()))
- .ToArray();
- }
-
- ///
- public override string ToString() => TypeInfo.ToString();
-
- ///
- public override bool Equals(object obj)
- {
- return Equals(obj as ITypeInfo);
- }
-
- ///
- public bool Equals(ITypeInfo other)
- {
- if (other == null)
- {
- return false;
- }
-
- var otherRuntimeType = other as RuntimeTypeInfo;
- if (otherRuntimeType != null)
- {
- return otherRuntimeType.TypeInfo == TypeInfo;
- }
-
- return string.Equals(
- SanitizedFullName,
- SanitizeFullName(other.FullName),
- StringComparison.Ordinal);
- }
-
- ///
- public override int GetHashCode() => SanitizedFullName.GetHashCode();
-
- ///
- /// Removes assembly qualification from generic type parameters for the specified .
- ///
- /// Full name.
- /// Full name without fully qualified generic parameters.
- ///
- /// typeof().FullName is
- /// List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]
- /// Sanitize(typeof(.FullName returns
- /// List`1[[System.String]
- ///
- public static string SanitizeFullName(string fullName)
- {
- // In CoreCLR, some types (such as System.String) are type forwarded from System.Runtime
- // to mscorlib at runtime. Type names of generic type parameters includes the assembly qualified name;
- // consequently the type name generated at precompilation differs from the one at runtime. We'll
- // avoid dealing with these inconsistencies by removing assembly information from TypeInfo.FullName.
- return _fullNameSanitizer.Replace(fullName, string.Empty);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/TagHelperDescriptorFactory.cs b/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/TagHelperDescriptorFactory.cs
index aae43d1ab8..a007dc7f10 100644
--- a/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/TagHelperDescriptorFactory.cs
+++ b/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/TagHelperDescriptorFactory.cs
@@ -9,11 +9,12 @@ using System.Reflection;
using System.Text.RegularExpressions;
using Microsoft.AspNet.Razor.Compilation.TagHelpers;
using Microsoft.AspNet.Razor.TagHelpers;
+using Microsoft.Extensions.Internal;
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
{
///
- /// Factory for s from s.
+ /// Factory for s from s.
///
public class TagHelperDescriptorFactory
{
@@ -31,8 +32,6 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
RegexOptions.None,
Constants.RegexMatchTimeout);
- private static readonly ITypeInfo StringTypeInfo = new RuntimeTypeInfo(typeof(string).GetTypeInfo());
-
#if !DOTNET5_4
private readonly TagHelperDesignTimeDescriptorFactory _designTimeDescriptorFactory;
#endif
@@ -63,24 +62,24 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
}
///
- /// Creates a from the given .
+ /// Creates a from the given .
///
/// The assembly name that contains .
- /// The to create a from.
+ /// The to create a from.
///
/// The used to collect s encountered
- /// when creating s for the given .
+ /// when creating s for the given .
///
- /// A collection of s that describe the given .
+ /// A collection of s that describe the given .
///
public virtual IEnumerable CreateDescriptors(
string assemblyName,
- ITypeInfo typeInfo,
+ Type type,
ErrorSink errorSink)
{
- if (typeInfo == null)
+ if (type == null)
{
- throw new ArgumentNullException(nameof(typeInfo));
+ throw new ArgumentNullException(nameof(type));
}
if (errorSink == null)
@@ -88,18 +87,18 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
throw new ArgumentNullException(nameof(errorSink));
}
- if (ShouldSkipDescriptorCreation(typeInfo))
+ if (ShouldSkipDescriptorCreation(type.GetTypeInfo()))
{
return Enumerable.Empty();
}
- var attributeDescriptors = GetAttributeDescriptors(typeInfo, errorSink);
- var targetElementAttributes = GetValidHtmlTargetElementAttributes(typeInfo, errorSink);
- var allowedChildren = GetAllowedChildren(typeInfo, errorSink);
+ var attributeDescriptors = GetAttributeDescriptors(type, errorSink);
+ var targetElementAttributes = GetValidHtmlTargetElementAttributes(type, errorSink);
+ var allowedChildren = GetAllowedChildren(type, errorSink);
var tagHelperDescriptors =
BuildTagHelperDescriptors(
- typeInfo,
+ type,
assemblyName,
attributeDescriptors,
targetElementAttributes,
@@ -109,17 +108,18 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
}
private static IEnumerable GetValidHtmlTargetElementAttributes(
- ITypeInfo typeInfo,
+ Type type,
ErrorSink errorSink)
{
- var targetElementAttributes = typeInfo.GetCustomAttributes();
-
+ var targetElementAttributes = type
+ .GetTypeInfo()
+ .GetCustomAttributes(inherit: false);
return targetElementAttributes.Where(
attribute => ValidHtmlTargetElementAttributeNames(attribute, errorSink));
}
private IEnumerable BuildTagHelperDescriptors(
- ITypeInfo typeInfo,
+ Type type,
string assemblyName,
IEnumerable attributeDescriptors,
IEnumerable targetElementAttributes,
@@ -130,21 +130,16 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
#if !DOTNET5_4
if (_designTime)
{
- var runtimeTypeInfo = typeInfo as RuntimeTypeInfo;
- if (runtimeTypeInfo != null)
- {
- typeDesignTimeDescriptor =
- _designTimeDescriptorFactory.CreateDescriptor(runtimeTypeInfo.TypeInfo.AsType());
- }
+ typeDesignTimeDescriptor = _designTimeDescriptorFactory.CreateDescriptor(type);
}
#endif
- var typeName = typeInfo.FullName;
+ var typeName = type.FullName;
// If there isn't an attribute specifying the tag name derive it from the name
if (!targetElementAttributes.Any())
{
- var name = typeInfo.Name;
+ var name = type.Name;
if (name.EndsWith(TagHelperNameEnding, StringComparison.OrdinalIgnoreCase))
{
@@ -177,18 +172,16 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
typeDesignTimeDescriptor));
}
- private static IEnumerable GetAllowedChildren(ITypeInfo typeInfo, ErrorSink errorSink)
+ private static IEnumerable GetAllowedChildren(Type type, ErrorSink errorSink)
{
- var restrictChildrenAttribute = typeInfo
- .GetCustomAttributes()
- .FirstOrDefault();
+ var restrictChildrenAttribute = type.GetTypeInfo().GetCustomAttribute(inherit: false);
if (restrictChildrenAttribute == null)
{
return null;
}
var allowedChildren = restrictChildrenAttribute.ChildTags;
- var validAllowedChildren = GetValidAllowedChildren(allowedChildren, typeInfo.FullName, errorSink);
+ var validAllowedChildren = GetValidAllowedChildren(allowedChildren, type.FullName, errorSink);
if (validAllowedChildren.Any())
{
@@ -405,14 +398,14 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
return validName;
}
- private IEnumerable GetAttributeDescriptors(ITypeInfo type, ErrorSink errorSink)
+ private IEnumerable GetAttributeDescriptors(Type type, ErrorSink errorSink)
{
var attributeDescriptors = new List();
// Keep indexer descriptors separate to avoid sorting the combined list later.
var indexerDescriptors = new List();
- var accessibleProperties = type.Properties.Where(IsAccessibleProperty);
+ var accessibleProperties = type.GetRuntimeProperties().Where(IsAccessibleProperty);
foreach (var property in accessibleProperties)
{
if (ShouldSkipDescriptorCreation(property))
@@ -421,14 +414,14 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
}
var attributeNameAttribute = property
- .GetCustomAttributes()
+ .GetCustomAttributes(inherit: false)
.FirstOrDefault();
var hasExplicitName =
attributeNameAttribute != null && !string.IsNullOrEmpty(attributeNameAttribute.Name);
var attributeName = hasExplicitName ? attributeNameAttribute.Name : ToHtmlCase(property.Name);
TagHelperAttributeDescriptor mainDescriptor = null;
- if (property.HasPublicSetter)
+ if (property.SetMethod != null && property.SetMethod.IsPublic)
{
mainDescriptor = ToAttributeDescriptor(property, attributeName);
if (!ValidateTagHelperAttributeDescriptor(mainDescriptor, type, errorSink))
@@ -491,7 +484,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Internal for testing.
internal static bool ValidateTagHelperAttributeDescriptor(
TagHelperAttributeDescriptor attributeDescriptor,
- ITypeInfo parentType,
+ Type parentType,
ErrorSink errorSink)
{
string nameOrPrefix;
@@ -523,13 +516,11 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
nameOrPrefix);
}
- private bool ShouldSkipDescriptorCreation(IMemberInfo memberInfo)
+ private bool ShouldSkipDescriptorCreation(MemberInfo memberInfo)
{
if (_designTime)
{
- var editorBrowsableAttribute = memberInfo
- .GetCustomAttributes()
- .FirstOrDefault();
+ var editorBrowsableAttribute = memberInfo.GetCustomAttribute(inherit: false);
return editorBrowsableAttribute != null &&
editorBrowsableAttribute.State == EditorBrowsableState.Never;
@@ -540,7 +531,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
private static bool ValidateTagHelperAttributeNameOrPrefix(
string attributeNameOrPrefix,
- ITypeInfo parentType,
+ Type parentType,
string propertyName,
ErrorSink errorSink,
string nameOrPrefix)
@@ -608,28 +599,33 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
return isValid;
}
- private TagHelperAttributeDescriptor ToAttributeDescriptor(IPropertyInfo property, string attributeName)
+ private TagHelperAttributeDescriptor ToAttributeDescriptor(PropertyInfo property, string attributeName)
{
return ToAttributeDescriptor(
property,
attributeName,
property.PropertyType.FullName,
isIndexer: false,
- isStringProperty: StringTypeInfo.Equals(property.PropertyType));
+ isStringProperty: typeof(string) == property.PropertyType);
}
private TagHelperAttributeDescriptor ToIndexerAttributeDescriptor(
- IPropertyInfo property,
+ PropertyInfo property,
HtmlAttributeNameAttribute attributeNameAttribute,
- ITypeInfo parentType,
+ Type parentType,
ErrorSink errorSink,
string defaultPrefix,
out bool isInvalid)
{
isInvalid = false;
- var hasPublicSetter = property.HasPublicSetter;
- var dictionaryTypeArguments = property.PropertyType.GetGenericDictionaryParameters();
- if (!StringTypeInfo.Equals(dictionaryTypeArguments?[0]))
+ var hasPublicSetter = property.SetMethod != null && property.SetMethod.IsPublic;
+ var dictionaryTypeArguments = ClosedGenericMatcher.ExtractGenericInterface(
+ property.PropertyType,
+ typeof(IDictionary<,>))
+ ?.GenericTypeArguments
+ .Select(type => type.IsGenericParameter ? null : type)
+ .ToArray();
+ if (dictionaryTypeArguments?[0] != typeof(string))
{
if (attributeNameAttribute?.DictionaryAttributePrefix != null)
{
@@ -698,11 +694,11 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
attributeName: prefix,
typeName: dictionaryTypeArguments[1].FullName,
isIndexer: true,
- isStringProperty: StringTypeInfo.Equals(dictionaryTypeArguments[1]));
+ isStringProperty: typeof(string) == dictionaryTypeArguments[1]);
}
private TagHelperAttributeDescriptor ToAttributeDescriptor(
- IPropertyInfo property,
+ PropertyInfo property,
string attributeName,
string typeName,
bool isIndexer,
@@ -713,12 +709,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
#if !DOTNET5_4
if (_designTime)
{
- var runtimeProperty = property as RuntimePropertyInfo;
- if (runtimeProperty != null)
- {
- propertyDesignTimeDescriptor =
- _designTimeDescriptorFactory.CreateAttributeDescriptor(runtimeProperty.Property);
- }
+ propertyDesignTimeDescriptor = _designTimeDescriptorFactory.CreateAttributeDescriptor(property);
}
#endif
@@ -726,7 +717,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
{
Name = attributeName,
PropertyName = property.Name,
- IsEnum = property.PropertyType.IsEnum,
+ IsEnum = property.PropertyType.GetTypeInfo().IsEnum,
TypeName = typeName,
IsStringProperty = isStringProperty,
IsIndexer = isIndexer,
@@ -734,11 +725,13 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
};
}
- private static bool IsAccessibleProperty(IPropertyInfo property)
+ private static bool IsAccessibleProperty(PropertyInfo property)
{
// Accessible properties are those with public getters and without [HtmlAttributeNotBound].
- return property.HasPublicGetter &&
- property.GetCustomAttributes().FirstOrDefault() == null;
+ return property.GetIndexParameters().Length == 0 &&
+ property.GetMethod != null &&
+ property.GetMethod.IsPublic &&
+ property.GetCustomAttribute(inherit: false) == null;
}
///
diff --git a/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/TagHelperTypeResolver.cs b/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/TagHelperTypeResolver.cs
index e132ce345f..0bbd83831b 100644
--- a/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/TagHelperTypeResolver.cs
+++ b/src/Microsoft.AspNet.Razor.Runtime/Runtime/TagHelpers/TagHelperTypeResolver.cs
@@ -14,7 +14,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
///
public class TagHelperTypeResolver
{
- private static readonly ITypeInfo ITagHelperTypeInfo = new RuntimeTypeInfo(typeof(ITagHelper).GetTypeInfo());
+ private static readonly TypeInfo ITagHelperTypeInfo = typeof(ITagHelper).GetTypeInfo();
///
/// Locates valid types from the named .
@@ -25,8 +25,8 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
///
/// The used to record errors found when resolving
/// types.
- /// An of valid types.
- public IEnumerable Resolve(
+ /// An of valid types.
+ public IEnumerable Resolve(
string name,
SourceLocation documentLocation,
ErrorSink errorSink)
@@ -44,15 +44,15 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
Resources.TagHelperTypeResolver_TagHelperAssemblyNameCannotBeEmptyOrNull,
errorLength);
- return Enumerable.Empty();
+ return Type.EmptyTypes;
}
var assemblyName = new AssemblyName(name);
- IEnumerable libraryTypes;
+ IEnumerable libraryTypes;
try
{
- libraryTypes = GetTopLevelExportedTypes(assemblyName);
+ libraryTypes = GetExportedTypes(assemblyName);
}
catch (Exception ex)
{
@@ -63,31 +63,10 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
ex.Message),
name.Length);
- return Enumerable.Empty();
+ return Type.EmptyTypes;
}
- return libraryTypes.Where(IsTagHelper);
- }
-
- ///
- /// Returns all non-nested exported types from the given
- ///
- /// The to get s from.
- ///
- /// An of types exported from the given .
- ///
- protected virtual IEnumerable GetTopLevelExportedTypes(AssemblyName assemblyName)
- {
- if (assemblyName == null)
- {
- throw new ArgumentNullException(nameof(assemblyName));
- }
-
- var exportedTypeInfos = GetExportedTypes(assemblyName);
-
- return exportedTypeInfos
- .Where(typeInfo => !typeInfo.IsNested)
- .Select(typeInfo => new RuntimeTypeInfo(typeInfo));
+ return libraryTypes.Where(IsTagHelper).Select(t => t.AsType());
}
///
@@ -105,12 +84,14 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
}
// Internal for testing.
- internal virtual bool IsTagHelper(ITypeInfo typeInfo)
+ internal virtual bool IsTagHelper(TypeInfo typeInfo)
{
- return typeInfo.IsPublic &&
- !typeInfo.IsAbstract &&
- !typeInfo.IsGenericType &&
- typeInfo.ImplementsInterface(ITagHelperTypeInfo);
+ return
+ !typeInfo.IsNested &&
+ typeInfo.IsPublic &&
+ !typeInfo.IsAbstract &&
+ !typeInfo.IsGenericType &&
+ ITagHelperTypeInfo.IsAssignableFrom(typeInfo);
}
}
}
\ No newline at end of file
diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/RuntimePropertyInfoTest.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/RuntimePropertyInfoTest.cs
deleted file mode 100644
index 3cdf5b87d6..0000000000
--- a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/RuntimePropertyInfoTest.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Linq;
-using System.Reflection;
-using Microsoft.AspNet.Razor.TagHelpers;
-using Xunit;
-
-namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
-{
- public class RuntimePropertyInfoTest
- {
- [Fact]
- public void PropertyInfo_ReturnsMetadataOfAdaptingProperty()
- {
- // Arrange
- var property = GetPropertyInfo(nameof(TestType.Property));
- var runtimePropertyInfo = new RuntimePropertyInfo(property);
-
- // Act
- var actual = runtimePropertyInfo.Property;
-
- // Assert
- Assert.Same(property, actual);
- var runtimeTypeInfo = Assert.IsType(runtimePropertyInfo.PropertyType);
- Assert.Same(property.PropertyType, runtimeTypeInfo.TypeInfo);
- }
-
- [Theory]
- [InlineData(nameof(TestType.Property))]
- [InlineData(nameof(TestType.PrivateSetter))]
- [InlineData(nameof(TestType.PropertyWithoutSetter))]
- public void HasPublicGetter_ReturnsTrueIfGetterExistsAndIsPublic(string propertyName)
- {
- // Arrange
- var property = GetPropertyInfo(propertyName);
- var runtimePropertyInfo = new RuntimePropertyInfo(property);
-
- // Act
- var result = runtimePropertyInfo.HasPublicGetter;
-
- // Assert
- Assert.True(result);
- }
-
- [Theory]
- [InlineData(nameof(TestType.PrivateGetter))]
- [InlineData(nameof(TestType.PropertyWithoutGetter))]
- [InlineData("ProtectedProperty")]
- public void HasPublicGetter_ReturnsFalseIfGetterDoesNotExistOrIsNonPublic(string propertyName)
- {
- // Arrange
- var property = GetPropertyInfo(propertyName);
- var runtimePropertyInfo = new RuntimePropertyInfo(property);
-
- // Act
- var result = runtimePropertyInfo.HasPublicGetter;
-
- // Assert
- Assert.False(result);
- }
-
- [Theory]
- [InlineData(nameof(TestType.Property))]
- [InlineData(nameof(TestType.PrivateGetter))]
- [InlineData(nameof(TestType.PropertyWithoutGetter))]
- public void HasPublicSetter_ReturnsTrueIfSetterExistsAndIsPublic(string propertyName)
- {
- // Arrange
- var property = GetPropertyInfo(propertyName);
- var runtimePropertyInfo = new RuntimePropertyInfo(property);
-
- // Act
- var result = runtimePropertyInfo.HasPublicSetter;
-
- // Assert
- Assert.True(result);
- }
-
- [Theory]
- [InlineData(nameof(TestType.PrivateSetter))]
- [InlineData(nameof(TestType.PropertyWithoutSetter))]
- [InlineData("ProtectedProperty")]
- public void HasPublicSetter_ReturnsFalseIfGetterDoesNotExistOrIsNonPublic(string propertyName)
- {
- // Arrange
- var property = GetPropertyInfo(propertyName);
- var runtimePropertyInfo = new RuntimePropertyInfo(property);
-
- // Act
- var result = runtimePropertyInfo.HasPublicSetter;
-
- // Assert
- Assert.False(result);
- }
-
- [Fact]
- public void GetAttributes_ReturnsCustomAttributesOfSpecifiedType()
- {
- // Arrange
- var property = GetPropertyInfo(nameof(TestType.PropertyWithAttributes));
- var runtimeProperty = new RuntimePropertyInfo(property);
-
- // Act
- var attributes = property.GetCustomAttributes();
-
- // Assert
- var htmlAttributeName = Assert.Single(attributes);
- Assert.Equal("somename", htmlAttributeName.Name);
- }
-
- [Fact]
- public void GetAttributes_DoesNotInheritAttributes()
- {
- // Arrange
- var property = GetPropertyInfo(nameof(TestType.PropertyWithAttributes));
- var runtimeProperty = new RuntimePropertyInfo(property);
-
- // Act
- var attributes = property.GetCustomAttributes();
-
- // Assert
- Assert.Empty(attributes);
- }
-
- private static PropertyInfo GetPropertyInfo(string propertyName)
- {
- return typeof(TestType).GetRuntimeProperties()
- .FirstOrDefault(p => p.Name == propertyName);
- }
-
- public class BaseType
- {
- [HtmlAttributeNotBound]
- public virtual string PropertyWithAttributes { get; }
- }
-
- public class TestType : BaseType
- {
- public string Property { get; set; }
-
- public int PrivateSetter { get; private set; }
-
- public object PrivateGetter { private get; set; }
-
- protected DateTimeOffset ProtectedProperty { get; set; }
-
- public string PropertyWithoutGetter
- {
- set { }
- }
-
- public int PropertyWithoutSetter => 0;
-
- [HtmlAttributeName("somename")]
- public override string PropertyWithAttributes { get; }
- }
- }
-}
diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/RuntimeTagHelperDescriptorFactoryTest.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/RuntimeTagHelperDescriptorFactoryTest.cs
deleted file mode 100644
index d25c28939f..0000000000
--- a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/RuntimeTagHelperDescriptorFactoryTest.cs
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using Microsoft.AspNet.Razor.Compilation.TagHelpers;
-using Microsoft.AspNet.Razor.TagHelpers;
-using Microsoft.AspNet.Razor.Test.Internal;
-using Xunit;
-
-namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
-{
- public class RuntimeTagHelperDescriptorFactoryTest : TagHelperDescriptorFactoryTest
- {
- public override ITypeInfo GetTypeInfo(Type tagHelperType) =>
- new RuntimeTypeInfo(tagHelperType.GetTypeInfo());
-
- [Fact]
- public void CreateDescriptors_BuildsDescriptorsFromSimpleTypes()
- {
- // Arrange
- var errorSink = new ErrorSink();
- var objectAssemblyName = typeof(object).GetTypeInfo().Assembly.GetName().Name;
- var expectedDescriptor =
- CreateTagHelperDescriptor("object", "System.Object", objectAssemblyName);
- var factory = new TagHelperDescriptorFactory(designTime: false);
-
- // Act
- var descriptors = factory.CreateDescriptors(
- objectAssemblyName,
- GetTypeInfo(typeof(object)),
- errorSink: errorSink);
-
- // Assert
- Assert.Empty(errorSink.Errors);
- var descriptor = Assert.Single(descriptors);
- Assert.Equal(expectedDescriptor, descriptor, CaseSensitiveTagHelperDescriptorComparer.Default);
- }
-
- [Theory]
- [MemberData(nameof(TagHelperWithPrefixData))]
- public void CreateDescriptors_WithPrefixes_ReturnsExpectedAttributeDescriptors(
- Type tagHelperType,
- IEnumerable expectedAttributeDescriptors,
- string[] expectedErrorMessages)
- {
- // Arrange
- var errorSink = new ErrorSink();
- var factory = new TagHelperDescriptorFactory(designTime: false);
-
- // Act
- var descriptors = factory.CreateDescriptors(
- AssemblyName,
- GetTypeInfo(tagHelperType),
- errorSink: errorSink);
-
- // Assert
- var errors = errorSink.Errors.ToArray();
- Assert.Equal(expectedErrorMessages.Length, errors.Length);
-
- for (var i = 0; i < errors.Length; i++)
- {
- Assert.Equal(0, errors[i].Length);
- Assert.Equal(SourceLocation.Zero, errors[i].Location);
- Assert.Equal(expectedErrorMessages[i], errors[i].Message, StringComparer.Ordinal);
- }
-
- var descriptor = Assert.Single(descriptors);
- Assert.Equal(
- expectedAttributeDescriptors,
- descriptor.Attributes,
- TagHelperAttributeDescriptorComparer.Default);
- }
-
- // TagHelperDesignTimeDescriptors are not created in CoreCLR.
-#if !DNXCORE50
- public static TheoryData OutputElementHintData
- {
- get
- {
- // tagHelperType, expectedDescriptors
- return new TheoryData
- {
- {
- typeof(OutputElementHintTagHelper),
- new[]
- {
- new TagHelperDescriptor
- {
- TagName = "output-element-hint",
- TypeName = typeof(OutputElementHintTagHelper).FullName,
- AssemblyName = AssemblyName,
- DesignTimeDescriptor = new TagHelperDesignTimeDescriptor
- {
- OutputElementHint = "strong"
- }
- }
- }
- },
- {
- typeof(MulitpleDescriptorTagHelperWithOutputElementHint),
- new[]
- {
- new TagHelperDescriptor
- {
- TagName = "a",
- TypeName = typeof(MulitpleDescriptorTagHelperWithOutputElementHint).FullName,
- AssemblyName = AssemblyName,
- DesignTimeDescriptor = new TagHelperDesignTimeDescriptor
- {
- OutputElementHint = "div"
- }
- },
- new TagHelperDescriptor
- {
- TagName = "p",
- TypeName = typeof(MulitpleDescriptorTagHelperWithOutputElementHint).FullName,
- AssemblyName = AssemblyName,
- DesignTimeDescriptor = new TagHelperDesignTimeDescriptor
- {
- OutputElementHint = "div"
- }
- }
- }
- }
- };
- }
- }
-
- [Theory]
- [MemberData(nameof(OutputElementHintData))]
- public void CreateDescriptors_CreatesDesignTimeDescriptorsWithOutputElementHint(
- Type tagHelperType,
- TagHelperDescriptor[] expectedDescriptors)
- {
- // Arrange
- var errorSink = new ErrorSink();
- var factory = new TagHelperDescriptorFactory(designTime: true);
-
- // Act
- var descriptors = factory.CreateDescriptors(
- AssemblyName,
- GetTypeInfo(tagHelperType),
- errorSink: errorSink);
-
- // Assert
- Assert.Empty(errorSink.Errors);
-
- // We don't care about order. Mono returns reflected attributes differently so we need to ensure order
- // doesn't matter by sorting.
- descriptors = descriptors.OrderBy(descriptor => descriptor.TagName);
-
- Assert.Equal(expectedDescriptors, descriptors, CaseSensitiveTagHelperDescriptorComparer.Default);
- }
-#endif
- }
-}
\ No newline at end of file
diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/RuntimeTypeInfoTest.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/RuntimeTypeInfoTest.cs
deleted file mode 100644
index 0c9210d344..0000000000
--- a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/RuntimeTypeInfoTest.cs
+++ /dev/null
@@ -1,535 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Reflection;
-using System.Threading.Tasks;
-using Microsoft.AspNet.Razor.TagHelpers;
-using Microsoft.AspNet.Testing;
-using Xunit;
-
-namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
-{
- public class RuntimeTypeInfoTest
- {
- [Theory]
- [InlineData(typeof(int))]
- [InlineData(typeof(string))]
- [InlineData(typeof(Tuple<>))]
- [InlineData(typeof(Tuple<>))]
- [InlineData(typeof(IDictionary))]
- [InlineData(typeof(IDictionary>))]
- [InlineData(typeof(IList, Tuple>>>))]
- [InlineData(typeof(AbstractType))]
- [InlineData(typeof(PrivateType))]
- [InlineData(typeof(KnownKeyDictionary<>))]
- [InlineData(typeof(KnownKeyDictionary))]
- public void RuntimeTypeInfo_ReturnsMetadataOfAdaptingType(Type type)
- {
- // Arrange
- var typeInfo = type.GetTypeInfo();
- var runtimeTypeInfo = new RuntimeTypeInfo(typeInfo);
-
- // Act and Assert
- Assert.Same(typeInfo, runtimeTypeInfo.TypeInfo);
- Assert.Equal(typeInfo.Name, runtimeTypeInfo.Name);
- Assert.Equal(type.FullName, runtimeTypeInfo.FullName);
- Assert.Equal(typeInfo.IsAbstract, runtimeTypeInfo.IsAbstract);
- Assert.Equal(typeInfo.IsGenericType, runtimeTypeInfo.IsGenericType);
- Assert.Equal(typeInfo.IsPublic, runtimeTypeInfo.IsPublic);
- }
-
- [Fact]
- public void Properties_ReturnsPublicPropertiesOfAdaptingType()
- {
- // Arrange
- var typeInfo = typeof(SubType).GetTypeInfo();
- var runtimeTypeInfo = new RuntimeTypeInfo(typeInfo);
-
- // Act and Assert
- Assert.Collection(runtimeTypeInfo.Properties,
- property =>
- {
- Assert.IsType(property);
- Assert.Equal("Property1", property.Name);
- },
- property =>
- {
- Assert.IsType(property);
- Assert.Equal("Property2", property.Name);
- },
- property =>
- {
- Assert.IsType(property);
- Assert.Equal("Property3", property.Name);
- },
- property =>
- {
- Assert.IsType(property);
- Assert.Equal("Property4", property.Name);
- },
- property =>
- {
- Assert.IsType(property);
- Assert.Equal("BaseTypeProperty", property.Name);
- },
- property =>
- {
- Assert.IsType(property);
- Assert.Equal("ProtectedProperty", property.Name);
- });
- }
-
- [Fact]
- public void GetCustomAttributes_ReturnsAllAttributesOfType()
- {
- // Arrange
- var typeInfo = typeof(TypeWithAttributes).GetTypeInfo();
- var runtimeTypeInfo = new RuntimeTypeInfo(typeInfo);
- var expected = typeInfo.GetCustomAttributes();
-
- // Act
- var actual = runtimeTypeInfo.GetCustomAttributes();
-
- // Assert
- Assert.Equal(expected, actual);
- }
-
- [Fact]
- public void GetCustomAttributes_DoesNotInheritAttributesFromBaseType()
- {
- // Arrange
- var typeInfo = typeof(SubType).GetTypeInfo();
- var runtimeTypeInfo = new RuntimeTypeInfo(typeInfo);
-
- // Act
- var actual = runtimeTypeInfo.GetCustomAttributes();
-
- // Assert
- Assert.Empty(actual);
- }
-
- [Fact]
- public void ImplementsInterface_ThrowsIfArgumentIsNotRuntimeType()
- {
- // Arrange
- var typeInfo = new RuntimeTypeInfo(typeof(object).GetTypeInfo());
- var interfaceTypeInfo = new TestTypeInfo();
-
- // Act and Assert
- ExceptionAssert.ThrowsArgument(() => typeInfo.ImplementsInterface(interfaceTypeInfo),
- "interfaceTypeInfo",
- $"Argument must be an instance of '{typeof(RuntimeTypeInfo)}'.");
- }
-
- [Theory]
- [InlineData(typeof(ITagHelper), typeof(ITagHelper))]
- [InlineData(typeof(TagHelper), typeof(ITagHelper))]
- [InlineData(typeof(ImplementsITagHelper), typeof(ITagHelper))]
- [InlineData(typeof(DerivesFromTagHelper), typeof(ITagHelper))]
- [InlineData(typeof(Fake.ImplementsRealITagHelper), typeof(ITagHelper))]
- [InlineData(typeof(string), typeof(IEnumerable))]
- [InlineData(typeof(Dictionary), typeof(IDictionary))]
- [InlineData(typeof(List), typeof(IList))]
- [InlineData(typeof(IList), typeof(IEnumerable))]
- public void ImplementsInterface_ReturnsTrueIfTypeImplementsInterface(Type runtimeType, Type interfaceType)
- {
- // Arrange
- var runtimeTypeInfo = new RuntimeTypeInfo(runtimeType.GetTypeInfo());
- var interfaceTypeInfo = new RuntimeTypeInfo(interfaceType.GetTypeInfo());
-
- // Act
- var result = runtimeTypeInfo.ImplementsInterface(interfaceTypeInfo);
-
- // Assert
- Assert.True(result);
- }
-
- [Theory]
- [InlineData(typeof(string), typeof(object))]
- [InlineData(typeof(DerivesFromTagHelper), typeof(TagHelper))]
- [InlineData(typeof(string), typeof(ITagHelper))]
- [InlineData(typeof(string), typeof(IList))]
- [InlineData(typeof(SubType), typeof(ITagHelper))]
- [InlineData(typeof(Fake.DoesNotImplementRealITagHelper), typeof(ITagHelper))]
- [InlineData(typeof(IDictionary<,>), typeof(IDictionary))]
- public void ImplementsInterface_ReturnsTrueIfTypeDoesNotImplementInterface(Type runtimeType, Type interfaceType)
- {
- // Arrange
- var runtimeTypeInfo = new RuntimeTypeInfo(runtimeType.GetTypeInfo());
- var interfaceTypeInfo = new RuntimeTypeInfo(interfaceType.GetTypeInfo());
-
- // Act
- var result = runtimeTypeInfo.ImplementsInterface(interfaceTypeInfo);
-
- // Assert
- Assert.False(result);
- }
-
- [Theory]
- [InlineData(typeof(Dictionary), new[] { typeof(string), typeof(string) })]
- [InlineData(typeof(DerivesFromDictionary), new[] { typeof(int), typeof(object) })]
- [InlineData(typeof(ImplementsIDictionary), new[] { typeof(List), typeof(string) })]
- [InlineData(typeof(IDictionary>),
- new[] { typeof(string), typeof(IDictionary) })]
- [InlineData(typeof(KnownKeyDictionary),
- new[] { typeof(string), typeof(ImplementsIDictionary) })]
- public void GetGenericDictionaryParameters_ReturnsKeyAndValueParameterTypeNames(
- Type type,
- Type[] expectedTypes)
- {
- // Arrange
- var runtimeTypeInfo = new RuntimeTypeInfo(type.GetTypeInfo());
-
- // Act
- var actual = runtimeTypeInfo.GetGenericDictionaryParameters();
-
- // Assert
- Assert.Collection(actual,
- keyType =>
- {
- Assert.Equal(new RuntimeTypeInfo(expectedTypes[0].GetTypeInfo()), keyType);
- },
- valueType =>
- {
- Assert.Equal(new RuntimeTypeInfo(expectedTypes[1].GetTypeInfo()), valueType);
- });
- }
-
- [Fact]
- public void GetGenericDictionaryParameters_WorksWhenValueParameterIsOpen()
- {
- // Arrange
- var runtimeTypeInfo = new RuntimeTypeInfo(typeof(KnownKeyDictionary<>).GetTypeInfo());
-
- // Act
- var actual = runtimeTypeInfo.GetGenericDictionaryParameters();
-
- // Assert
- Assert.Collection(actual,
- keyType =>
- {
- Assert.Equal(new RuntimeTypeInfo(typeof(string).GetTypeInfo()), keyType);
- },
- valueType =>
- {
- Assert.Null(valueType);
- });
- }
-
- [Fact]
- public void GetGenericDictionaryParameters_WorksWhenKeyAndValueParametersAreOpen()
- {
- // Arrange
- var runtimeTypeInfo = new RuntimeTypeInfo(typeof(Dictionary<,>).GetTypeInfo());
-
- // Act
- var actual = runtimeTypeInfo.GetGenericDictionaryParameters();
-
- // Assert
- Assert.Equal(new RuntimeTypeInfo[] { null, null }, actual);
- }
-
- [Theory]
- [InlineData(typeof(int))]
- [InlineData(typeof(string))]
- [InlineData(typeof(List))]
- [InlineData(typeof(IDictionary))]
- [InlineData(typeof(ITagHelper))]
- public void GetGenericDictionaryParameterNames_ReturnsNullIfTypeDoesNotImplementGenericDictionary(Type type)
- {
- // Arrange
- var runtimeTypeInfo = new RuntimeTypeInfo(type.GetTypeInfo());
-
- // Act
- var actual = runtimeTypeInfo.GetGenericDictionaryParameters();
-
- // Assert
- Assert.Null(actual);
- }
-
- [Theory]
- [InlineData(typeof(string))]
- [InlineData(typeof(IDictionary<,>))]
- [InlineData(typeof(ITagHelper))]
- [InlineData(typeof(TagHelper))]
- public void Equals_ReturnsTrueIfTypeInfosAreIdentical(Type type)
- {
- // Arrange
- var typeA = new RuntimeTypeInfo(type.GetTypeInfo());
- var typeB = new RuntimeTypeInfo(type.GetTypeInfo());
-
- // Act
- var equals = typeA.Equals(typeB);
- var hashCodeA = typeA.GetHashCode();
- var hashCodeB = typeB.GetHashCode();
-
- // Assert
- Assert.True(equals);
- Assert.Equal(hashCodeA, hashCodeB);
- }
-
- public static TheoryData Equals_ReturnsTrueIfTypeFullNamesAreIdenticalData =>
- new TheoryData
- {
- { typeof(string), typeof(string).FullName },
- { typeof(ITagHelper), typeof(ITagHelper).FullName },
- { typeof(TagHelper), typeof(TagHelper).FullName },
- { typeof(TagHelper), typeof(TagHelper).FullName },
- { typeof(IDictionary<,>), typeof(IDictionary<,>).FullName },
- {
- typeof(IDictionary),
- typeof(IDictionary).FullName
- },
- };
-
- [Theory]
- [MemberData(nameof(Equals_ReturnsTrueIfTypeFullNamesAreIdenticalData))]
- public void Equals_ReturnsTrueIfTypeInfoNamesAreIdentical(Type type, string fullName)
- {
- // Arrange
- var typeA = new RuntimeTypeInfo(type.GetTypeInfo());
- var typeB = new TestTypeInfo
- {
- FullName = fullName
- };
-
- // Act
- var equals = typeA.Equals(typeB);
-
- // Assert
- Assert.True(equals);
- }
-
- [Theory]
- [InlineData(typeof(string), typeof(object))]
- [InlineData(typeof(IDictionary<,>), typeof(IDictionary))]
- [InlineData(typeof(KnownKeyDictionary), typeof(IDictionary))]
- [InlineData(typeof(ITagHelper), typeof(TagHelper))]
- public void Equals_ReturnsFalseIfTypeInfosAreDifferent(Type typeA, Type typeB)
- {
- // Arrange
- var typeAInfo = new RuntimeTypeInfo(typeA.GetTypeInfo());
- var typeBInfo = new RuntimeTypeInfo(typeB.GetTypeInfo());
-
- // Act
- var equals = typeAInfo.Equals(typeBInfo);
- var hashCodeA = typeAInfo.GetHashCode();
- var hashCodeB = typeBInfo.GetHashCode();
-
- // Assert
- Assert.False(equals);
- Assert.NotEqual(hashCodeA, hashCodeB);
- }
-
- [Theory]
- [MemberData(nameof(Equals_ReturnsTrueIfTypeFullNamesAreIdenticalData))]
- public void Equals_ReturnsFalseIfTypeInfoNamesAreDifferent(Type type, string fullName)
- {
- // Arrange
- var typeA = new RuntimeTypeInfo(type.GetTypeInfo());
- var typeB = new TestTypeInfo
- {
- FullName = "Different" + fullName
- };
-
- // Act
- var equals = typeA.Equals(typeB);
-
- // Assert
- Assert.False(equals);
- }
-
- public class AbstractType
- {
- }
-
- internal class InternalType
- {
- }
-
- private class PrivateType
- {
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- private class BaseType
- {
- public string this[string key]
- {
- get { return ""; }
- set { }
- }
-
- public string BaseTypeProperty { get; set; }
-
- protected int ProtectedProperty { get; set; }
- }
-
- private class SubType : BaseType
- {
- public string Property1 { get; set; }
-
- public int Property2 { get; }
-
- public object Property3 { private get; set; }
-
- private int Property4 { get; set; }
- }
-
- [HtmlTargetElement("test1")]
- [HtmlTargetElement("test2")]
- private class TypeWithAttributes
- {
- }
-
- private class DerivesFromTagHelper : TagHelper
- {
- }
-
- private class ImplementsITagHelper : ITagHelper
- {
- public int Order { get; } = 0;
-
- public void Init(TagHelperContext context)
- {
- }
-
- public Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
- {
- throw new NotImplementedException();
- }
- }
-
- private class DerivesFromDictionary : Dictionary
- {
- }
-
- private class ImplementsIDictionary : IDictionary, string>, IReadOnlyList
- {
- public int this[int index]
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public string this[List key]
- {
- get
- {
- throw new NotImplementedException();
- }
-
- set
- {
- throw new NotImplementedException();
- }
- }
-
- public int Count
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public bool IsReadOnly
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public ICollection> Keys
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public ICollection Values
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public void Add(KeyValuePair, string> item)
- {
- throw new NotImplementedException();
- }
-
- public void Add(List key, string value)
- {
- throw new NotImplementedException();
- }
-
- public void Clear()
- {
- throw new NotImplementedException();
- }
-
- public bool Contains(KeyValuePair, string> item)
- {
- throw new NotImplementedException();
- }
-
- public bool ContainsKey(List key)
- {
- throw new NotImplementedException();
- }
-
- public void CopyTo(KeyValuePair, string>[] array, int arrayIndex)
- {
- throw new NotImplementedException();
- }
-
- public IEnumerator, string>> GetEnumerator()
- {
- throw new NotImplementedException();
- }
-
- public bool Remove(KeyValuePair, string> item)
- {
- throw new NotImplementedException();
- }
-
- public bool Remove(List key)
- {
- throw new NotImplementedException();
- }
-
- public bool TryGetValue(List key, out string value)
- {
- throw new NotImplementedException();
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- throw new NotImplementedException();
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- throw new NotImplementedException();
- }
- }
-
- public class KnownKeyDictionary : Dictionary
- {
- }
-
- private class CustomType
- {
- }
- }
-}
\ No newline at end of file
diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TagHelperDescriptorFactoryTest.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TagHelperDescriptorFactoryTest.cs
index 4a396613b3..fca90b4286 100644
--- a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TagHelperDescriptorFactoryTest.cs
+++ b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TagHelperDescriptorFactoryTest.cs
@@ -12,7 +12,7 @@ using Xunit;
namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
{
- public abstract class TagHelperDescriptorFactoryTest
+ public class TagHelperDescriptorFactoryTest
{
protected static readonly AssemblyName TagHelperDescriptorFactoryTestAssembly =
typeof(TagHelperDescriptorFactoryTest).GetTypeInfo().Assembly.GetName();
@@ -93,7 +93,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(tagHelperType),
+ tagHelperType,
errorSink: errorSink);
// Assert
@@ -182,7 +182,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(tagHelperType),
+ tagHelperType,
errorSink: errorSink);
// Assert
@@ -252,7 +252,6 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
}
}
- public abstract ITypeInfo GetTypeInfo(Type tagHelperType);
[Theory]
[MemberData(nameof(RestrictChildrenData))]
@@ -267,7 +266,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(tagHelperType),
+ tagHelperType,
errorSink: errorSink);
// Assert
@@ -356,7 +355,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(tagHelperType),
+ tagHelperType,
errorSink: errorSink);
// Assert
@@ -592,7 +591,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(tagHelperType),
+ tagHelperType,
errorSink);
// Assert
@@ -794,7 +793,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(tagHelperType),
+ tagHelperType,
errorSink: errorSink);
// Assert
@@ -843,7 +842,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(tagHelperType),
+ tagHelperType,
errorSink: errorSink);
// Assert
@@ -880,7 +879,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(typeof(OverriddenAttributeTagHelper)),
+ typeof(OverriddenAttributeTagHelper),
errorSink: errorSink);
// Assert
@@ -914,7 +913,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(typeof(InheritedOverriddenAttributeTagHelper)),
+ typeof(InheritedOverriddenAttributeTagHelper),
errorSink: errorSink);
// Assert
@@ -948,7 +947,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(typeof(InheritedNotOverriddenAttributeTagHelper)),
+ typeof(InheritedNotOverriddenAttributeTagHelper),
errorSink: errorSink);
// Assert
Assert.Empty(errorSink.Errors);
@@ -978,7 +977,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(typeof(InheritedSingleAttributeTagHelper)),
+ typeof(InheritedSingleAttributeTagHelper),
errorSink: errorSink);
// Assert
@@ -1006,7 +1005,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(typeof(SingleAttributeTagHelper)),
+ typeof(SingleAttributeTagHelper),
errorSink: new ErrorSink());
// Assert
@@ -1035,7 +1034,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(typeof(MissingAccessorTagHelper)),
+ typeof(MissingAccessorTagHelper),
errorSink: errorSink);
// Assert
@@ -1064,7 +1063,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(typeof(NonPublicAccessorTagHelper)),
+ typeof(NonPublicAccessorTagHelper),
errorSink: errorSink);
// Assert
@@ -1096,7 +1095,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(typeof(NotBoundAttributeTagHelper)),
+ typeof(NotBoundAttributeTagHelper),
errorSink: errorSink);
// Assert
@@ -1115,7 +1114,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(typeof(DuplicateAttributeNameTagHelper)),
+ typeof(DuplicateAttributeNameTagHelper),
errorSink: errorSink);
// Assert
@@ -1164,7 +1163,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(typeof(MultiTagTagHelper)),
+ typeof(MultiTagTagHelper),
errorSink: errorSink);
// Assert
@@ -1196,7 +1195,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(typeof(InheritedMultiTagTagHelper)),
+ typeof(InheritedMultiTagTagHelper),
errorSink: errorSink);
// Assert
@@ -1226,7 +1225,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(typeof(DuplicateTagNameTagHelper)),
+ typeof(DuplicateTagNameTagHelper),
errorSink: errorSink);
// Assert
@@ -1256,7 +1255,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(typeof(OverrideNameTagHelper)),
+ typeof(OverrideNameTagHelper),
errorSink: errorSink);
// Assert
@@ -1444,7 +1443,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var descriptors = factory.CreateDescriptors(
AssemblyName,
- GetTypeInfo(type),
+ type,
errorSink: errorSink);
// Assert
@@ -1694,7 +1693,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var result = TagHelperDescriptorFactory.ValidateTagHelperAttributeDescriptor(
descriptor,
- GetTypeInfo(typeof(MultiTagTagHelper)),
+ typeof(MultiTagTagHelper),
errorSink);
// Assert
@@ -1736,7 +1735,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var result = TagHelperDescriptorFactory.ValidateTagHelperAttributeDescriptor(
descriptor,
- GetTypeInfo(typeof(MultiTagTagHelper)),
+ typeof(MultiTagTagHelper),
errorSink);
// Assert
@@ -1782,7 +1781,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var result = TagHelperDescriptorFactory.ValidateTagHelperAttributeDescriptor(
descriptor,
- GetTypeInfo(typeof(MultiTagTagHelper)),
+ typeof(MultiTagTagHelper),
errorSink);
// Assert
@@ -1837,7 +1836,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Act
var result = TagHelperDescriptorFactory.ValidateTagHelperAttributeDescriptor(
descriptor,
- GetTypeInfo(typeof(MultiTagTagHelper)),
+ typeof(MultiTagTagHelper),
errorSink);
// Assert
@@ -1925,6 +1924,145 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
Assert.Equal(expectedErrors, errorSink.Errors);
}
+ [Fact]
+ public void CreateDescriptors_BuildsDescriptorsFromSimpleTypes()
+ {
+ // Arrange
+ var errorSink = new ErrorSink();
+ var objectAssemblyName = typeof(object).GetTypeInfo().Assembly.GetName().Name;
+ var expectedDescriptor =
+ CreateTagHelperDescriptor("object", "System.Object", objectAssemblyName);
+ var factory = new TagHelperDescriptorFactory(designTime: false);
+
+ // Act
+ var descriptors = factory.CreateDescriptors(
+ objectAssemblyName,
+ typeof(object),
+ errorSink: errorSink);
+
+ // Assert
+ Assert.Empty(errorSink.Errors);
+ var descriptor = Assert.Single(descriptors);
+ Assert.Equal(expectedDescriptor, descriptor, CaseSensitiveTagHelperDescriptorComparer.Default);
+ }
+
+ [Theory]
+ [MemberData(nameof(TagHelperWithPrefixData))]
+ public void CreateDescriptors_WithPrefixes_ReturnsExpectedAttributeDescriptors(
+ Type tagHelperType,
+ IEnumerable expectedAttributeDescriptors,
+ string[] expectedErrorMessages)
+ {
+ // Arrange
+ var errorSink = new ErrorSink();
+ var factory = new TagHelperDescriptorFactory(designTime: false);
+
+ // Act
+ var descriptors = factory.CreateDescriptors(
+ AssemblyName,
+ tagHelperType,
+ errorSink: errorSink);
+
+ // Assert
+ var errors = errorSink.Errors.ToArray();
+ Assert.Equal(expectedErrorMessages.Length, errors.Length);
+
+ for (var i = 0; i < errors.Length; i++)
+ {
+ Assert.Equal(0, errors[i].Length);
+ Assert.Equal(SourceLocation.Zero, errors[i].Location);
+ Assert.Equal(expectedErrorMessages[i], errors[i].Message, StringComparer.Ordinal);
+ }
+
+ var descriptor = Assert.Single(descriptors);
+ Assert.Equal(
+ expectedAttributeDescriptors,
+ descriptor.Attributes,
+ TagHelperAttributeDescriptorComparer.Default);
+ }
+
+ // TagHelperDesignTimeDescriptors are not created in CoreCLR.
+#if !DNXCORE50
+ public static TheoryData OutputElementHintData
+ {
+ get
+ {
+ // tagHelperType, expectedDescriptors
+ return new TheoryData
+ {
+ {
+ typeof(OutputElementHintTagHelper),
+ new[]
+ {
+ new TagHelperDescriptor
+ {
+ TagName = "output-element-hint",
+ TypeName = typeof(OutputElementHintTagHelper).FullName,
+ AssemblyName = AssemblyName,
+ DesignTimeDescriptor = new TagHelperDesignTimeDescriptor
+ {
+ OutputElementHint = "strong"
+ }
+ }
+ }
+ },
+ {
+ typeof(MulitpleDescriptorTagHelperWithOutputElementHint),
+ new[]
+ {
+ new TagHelperDescriptor
+ {
+ TagName = "a",
+ TypeName = typeof(MulitpleDescriptorTagHelperWithOutputElementHint).FullName,
+ AssemblyName = AssemblyName,
+ DesignTimeDescriptor = new TagHelperDesignTimeDescriptor
+ {
+ OutputElementHint = "div"
+ }
+ },
+ new TagHelperDescriptor
+ {
+ TagName = "p",
+ TypeName = typeof(MulitpleDescriptorTagHelperWithOutputElementHint).FullName,
+ AssemblyName = AssemblyName,
+ DesignTimeDescriptor = new TagHelperDesignTimeDescriptor
+ {
+ OutputElementHint = "div"
+ }
+ }
+ }
+ }
+ };
+ }
+ }
+
+ [Theory]
+ [MemberData(nameof(OutputElementHintData))]
+ public void CreateDescriptors_CreatesDesignTimeDescriptorsWithOutputElementHint(
+ Type tagHelperType,
+ TagHelperDescriptor[] expectedDescriptors)
+ {
+ // Arrange
+ var errorSink = new ErrorSink();
+ var factory = new TagHelperDescriptorFactory(designTime: true);
+
+ // Act
+ var descriptors = factory.CreateDescriptors(
+ AssemblyName,
+ tagHelperType,
+ errorSink: errorSink);
+
+ // Assert
+ Assert.Empty(errorSink.Errors);
+
+ // We don't care about order. Mono returns reflected attributes differently so we need to ensure order
+ // doesn't matter by sorting.
+ descriptors = descriptors.OrderBy(descriptor => descriptor.TagName);
+
+ Assert.Equal(expectedDescriptors, descriptors, CaseSensitiveTagHelperDescriptorComparer.Default);
+ }
+#endif
+
private static TheoryData GetInvalidNameOrPrefixData(
Func onNameError,
string whitespaceErrorString,
diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TagHelperDescriptorResolverTest.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TagHelperDescriptorResolverTest.cs
index ca6241f0f0..bd6563bcb6 100644
--- a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TagHelperDescriptorResolverTest.cs
+++ b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TagHelperDescriptorResolverTest.cs
@@ -1414,7 +1414,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
return types?.Select(type => type.GetTypeInfo()) ?? Enumerable.Empty();
}
- internal override bool IsTagHelper(ITypeInfo typeInfo)
+ internal override bool IsTagHelper(TypeInfo typeInfo)
{
return true;
}
diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TagHelperTypeResolverTest.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TagHelperTypeResolverTest.cs
index 10800f6d66..734e34806a 100644
--- a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TagHelperTypeResolverTest.cs
+++ b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TagHelperTypeResolverTest.cs
@@ -66,13 +66,11 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
Assert.Collection(types,
type =>
{
- var typeInfo = Assert.IsType(type);
- Assert.Equal(typeof(Valid_PlainTagHelper).GetTypeInfo(), typeInfo.TypeInfo);
+ Assert.Equal(typeof(Valid_PlainTagHelper), type);
},
type =>
{
- var typeInfo = Assert.IsType(type);
- Assert.Equal(typeof(Valid_InheritedTagHelper).GetTypeInfo(), typeInfo.TypeInfo);
+ Assert.Equal(typeof(Valid_InheritedTagHelper), type);
});
}
diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/DoesNotImplementRealITagHelper.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/DoesNotImplementRealITagHelper.cs
deleted file mode 100644
index b1ed2ee105..0000000000
--- a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/DoesNotImplementRealITagHelper.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-namespace Microsoft.AspNet.Razor.Fake
-{
- public class DoesNotImplementRealITagHelper : Microsoft.AspNet.Razor.Fake.ITagHelper
- {
- }
-}
diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/IFakeTagHelper.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/IFakeTagHelper.cs
deleted file mode 100644
index 560b395b3c..0000000000
--- a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/IFakeTagHelper.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Threading.Tasks;
-using Microsoft.AspNet.Razor.TagHelpers;
-
-namespace Microsoft.AspNet.Razor.Fake
-{
- public interface ITagHelper
- {
-
- }
-}
\ No newline at end of file
diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/ImplementsRealTagHelper.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/ImplementsRealTagHelper.cs
deleted file mode 100644
index e1a9536cfc..0000000000
--- a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/ImplementsRealTagHelper.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Threading.Tasks;
-using Microsoft.AspNet.Razor.TagHelpers;
-
-namespace Microsoft.AspNet.Razor.Fake
-{
- public class ImplementsRealITagHelper : Microsoft.AspNet.Razor.TagHelpers.ITagHelper
- {
- public int Order
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public void Init(TagHelperContext context)
- {
- }
-
- public Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
- {
- throw new NotImplementedException();
- }
- }
-
-}
diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/TagHelperDescriptorFactoryTagHelpers.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/TagHelperDescriptorFactoryTagHelpers.cs
index a5636b82fc..08fdc38b8d 100644
--- a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/TagHelperDescriptorFactoryTagHelpers.cs
+++ b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/TagHelperDescriptorFactoryTagHelpers.cs
@@ -429,58 +429,4 @@ namespace Microsoft.AspNet.Razor.TagHelpers
public class MulitpleDescriptorTagHelperWithOutputElementHint : TagHelper
{
}
-
- public class TypeDerivingFromITagHelper : ITagHelper
- {
- public int Order { get; } = 0;
-
- public void Init(TagHelperContext context)
- {
- }
-
- public Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
- {
- throw new NotImplementedException();
- }
- }
-
- public class BaseAttribute : Attribute
- {
- public string BaseProperty { get; set; }
- }
-
- public class DerivedAttribute : BaseAttribute
- {
- public string DerivedProperty { get; set; }
- }
-
- public class BaseTagHelper : TagHelper
- {
- [Derived(DerivedProperty = "DerivedPropertyValue")]
- public string BaseProperty { get; set; }
-
- [HtmlAttributeNotBound]
- public virtual string VirtualProperty { get; set; }
-
- public int NewProperty { get; set; }
-
- public virtual new string Order { get; set; }
- }
-
- public class DerivedTagHelper : BaseTagHelper
- {
- public override string VirtualProperty { get; set; }
-
- [Base(BaseProperty = "BaseValue")]
- public string DerivedProperty { get; set; }
-
- [HtmlAttributeName("new-property")]
- public new Type NewProperty { get; set; }
-
- public override string Order { get; set; }
- }
-}
-
-public class TagHelperInGlobalNamespace : TagHelper
-{
}
diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/TestTypeInfo.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/TestTypeInfo.cs
deleted file mode 100644
index 212906d204..0000000000
--- a/test/Microsoft.AspNet.Razor.Runtime.Test/Runtime/TagHelpers/TestTagHelpers/TestTypeInfo.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-
-namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
-{
- public class TestTypeInfo : ITypeInfo
- {
- public string FullName { get; set; }
-
- public bool IsAbstract
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public bool IsGenericType
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public bool IsPublic
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public bool IsEnum
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public bool ImplementsInterface(ITypeInfo other)
- {
- throw new NotImplementedException();
- }
-
- public string Name
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public IEnumerable Properties
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public bool Equals(ITypeInfo other)
- {
- throw new NotImplementedException();
- }
-
- public IEnumerable GetCustomAttributes() where TAttribute : Attribute
- {
- throw new NotImplementedException();
- }
-
- public ITypeInfo[] GetGenericDictionaryParameters()
- {
- throw new NotImplementedException();
- }
- }
-}