Correct route provider attribute usages (fixes #1405).
Also cleanup redundant attribute usage attributes on MVC filter overrides.
This commit is contained in:
Родитель
d778f9c0f9
Коммит
9cac3aebf5
|
@ -16,6 +16,7 @@ namespace System.Web.Mvc.Routing
|
|||
#endif
|
||||
{
|
||||
/// <summary>Represents an attribute route that may contain custom constraints.</summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = false, AllowMultiple = true)]
|
||||
public abstract class RouteProviderAttribute : Attribute, IDirectRouteProvider
|
||||
{
|
||||
private readonly string _template;
|
||||
|
|
|
@ -5,7 +5,6 @@ using System.Web.Mvc.Filters;
|
|||
namespace System.Web.Mvc
|
||||
{
|
||||
/// <summary>Represents a filter attribute that overrides action filters defined at a higher level.</summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
|
||||
public sealed class OverrideActionFiltersAttribute : FilterAttribute, IOverrideFilter
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -7,7 +7,6 @@ namespace System.Web.Mvc
|
|||
/// <summary>
|
||||
/// Represents a filter attribute that overrides authentication filters defined at a higher level.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
|
||||
public sealed class OverrideAuthenticationAttribute : FilterAttribute, IOverrideFilter
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -7,7 +7,6 @@ namespace System.Web.Mvc
|
|||
/// <summary>
|
||||
/// Represents a filter attribute that overrides authorization filters defined at a higher level.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
|
||||
public sealed class OverrideAuthorizationAttribute : FilterAttribute, IOverrideFilter
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -5,7 +5,6 @@ using System.Web.Mvc.Filters;
|
|||
namespace System.Web.Mvc
|
||||
{
|
||||
/// <summary>Represents a filter attribute that overrides exception filters defined at a higher level.</summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
|
||||
public sealed class OverrideExceptionFiltersAttribute : FilterAttribute, IOverrideFilter
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -5,7 +5,6 @@ using System.Web.Mvc.Filters;
|
|||
namespace System.Web.Mvc
|
||||
{
|
||||
/// <summary>Represents a filter attribute that overrides result filters defined at a higher level.</summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
|
||||
public sealed class OverrideResultFiltersAttribute : FilterAttribute, IOverrideFilter
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -253,6 +253,20 @@ namespace System.Web.Mvc.Routing
|
|||
Assert.Same(existingConstraints, constraints);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AttributeUsage_IsAsSpecified()
|
||||
{
|
||||
// Act
|
||||
AttributeUsageAttribute usage = (AttributeUsageAttribute)Attribute.GetCustomAttribute(
|
||||
typeof(RouteProviderAttribute), typeof(AttributeUsageAttribute));
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(usage);
|
||||
Assert.Equal(AttributeTargets.Class | AttributeTargets.Method, usage.ValidOn);
|
||||
Assert.Equal(false, usage.Inherited);
|
||||
Assert.Equal(true, usage.AllowMultiple);
|
||||
}
|
||||
|
||||
private static DirectRouteBuilder CreateBuilder(Func<RouteEntry> build)
|
||||
{
|
||||
return new LambdaDirectRouteBuilder(build);
|
||||
|
|
Загрузка…
Ссылка в новой задаче