[Fixes #4506] Move and rename ActionDescriptor.Name to ControllerActionDescriptor.ActionName
This commit is contained in:
parent
5f4ca4fa66
commit
6a6d2e0d9f
|
|
@ -24,8 +24,6 @@ namespace Microsoft.AspNetCore.Mvc.Abstractions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Id { get; }
|
public string Id { get; }
|
||||||
|
|
||||||
public virtual string Name { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the collection of route values that must be provided by routing
|
/// Gets or sets the collection of route values that must be provided by routing
|
||||||
/// for the action to be selected.
|
/// for the action to be selected.
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ namespace Microsoft.AspNetCore.Mvc.Controllers
|
||||||
{
|
{
|
||||||
public string ControllerName { get; set; }
|
public string ControllerName { get; set; }
|
||||||
|
|
||||||
|
public virtual string ActionName { get; set; }
|
||||||
|
|
||||||
public MethodInfo MethodInfo { get; set; }
|
public MethodInfo MethodInfo { get; set; }
|
||||||
|
|
||||||
public TypeInfo ControllerTypeInfo { get; set; }
|
public TypeInfo ControllerTypeInfo { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
|
|
||||||
var actionDescriptor = new ControllerActionDescriptor()
|
var actionDescriptor = new ControllerActionDescriptor()
|
||||||
{
|
{
|
||||||
Name = action.ActionName,
|
ActionName = action.ActionName,
|
||||||
MethodInfo = action.ActionMethod,
|
MethodInfo = action.ActionMethod,
|
||||||
Parameters = parameterDescriptors,
|
Parameters = parameterDescriptors,
|
||||||
AttributeRouteInfo = CreateAttributeRouteInfo(actionAttributeRoute, controllerAttributeRoute)
|
AttributeRouteInfo = CreateAttributeRouteInfo(actionAttributeRoute, controllerAttributeRoute)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Mvc.Routing
|
||||||
/// <para>
|
/// <para>
|
||||||
/// The typical scheme for action selection in an MVC application is that an action will require the
|
/// The typical scheme for action selection in an MVC application is that an action will require the
|
||||||
/// matching values for its <see cref="ControllerActionDescriptor.ControllerName"/> and
|
/// matching values for its <see cref="ControllerActionDescriptor.ControllerName"/> and
|
||||||
/// <see cref="ActionDescriptor.Name"/>
|
/// <see cref="ControllerActionDescriptor.ActionName"/>
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// For an action like <code>MyApp.Controllers.HomeController.Index()</code>, in order to be selected, the
|
/// For an action like <code>MyApp.Controllers.HomeController.Index()</code>, in order to be selected, the
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||||
using Microsoft.AspNetCore.Mvc.Internal;
|
using Microsoft.AspNetCore.Mvc.Internal;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
|
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
|
||||||
|
|
@ -19,6 +20,8 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PartialViewResultExecutor : ViewExecutor
|
public class PartialViewResultExecutor : ViewExecutor
|
||||||
{
|
{
|
||||||
|
private const string ActionNameKey = "action";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="PartialViewResultExecutor"/>.
|
/// Creates a new <see cref="PartialViewResultExecutor"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -69,7 +72,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
|
||||||
}
|
}
|
||||||
|
|
||||||
var viewEngine = viewResult.ViewEngine ?? ViewEngine;
|
var viewEngine = viewResult.ViewEngine ?? ViewEngine;
|
||||||
var viewName = viewResult.ViewName ?? actionContext.ActionDescriptor.Name;
|
var viewName = viewResult.ViewName ?? GetActionName(actionContext);
|
||||||
|
|
||||||
var result = viewEngine.GetView(executingFilePath: null, viewPath: viewName, isMainPage: false);
|
var result = viewEngine.GetView(executingFilePath: null, viewPath: viewName, isMainPage: false);
|
||||||
var originalResult = result;
|
var originalResult = result;
|
||||||
|
|
@ -157,5 +160,47 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
|
||||||
viewResult.ContentType,
|
viewResult.ContentType,
|
||||||
viewResult.StatusCode);
|
viewResult.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetActionName(ActionContext context)
|
||||||
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
object routeValue;
|
||||||
|
if (!context.RouteData.Values.TryGetValue(ActionNameKey, out routeValue))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var actionDescriptor = context.ActionDescriptor;
|
||||||
|
string normalizedValue = null;
|
||||||
|
if (actionDescriptor.AttributeRouteInfo != null)
|
||||||
|
{
|
||||||
|
object match;
|
||||||
|
if (actionDescriptor.RouteValueDefaults.TryGetValue(ActionNameKey, out match))
|
||||||
|
{
|
||||||
|
normalizedValue = match?.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string value;
|
||||||
|
if (actionDescriptor.RouteValues.TryGetValue(ActionNameKey, out value) &&
|
||||||
|
!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
normalizedValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var stringRouteValue = routeValue?.ToString();
|
||||||
|
if (string.Equals(normalizedValue, stringRouteValue, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return normalizedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return stringRouteValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||||
using Microsoft.AspNetCore.Mvc.Internal;
|
using Microsoft.AspNetCore.Mvc.Internal;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
|
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
|
||||||
|
|
@ -19,6 +20,8 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ViewResultExecutor : ViewExecutor
|
public class ViewResultExecutor : ViewExecutor
|
||||||
{
|
{
|
||||||
|
private const string ActionNameKey = "action";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="ViewResultExecutor"/>.
|
/// Creates a new <see cref="ViewResultExecutor"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -69,7 +72,8 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
|
||||||
}
|
}
|
||||||
|
|
||||||
var viewEngine = viewResult.ViewEngine ?? ViewEngine;
|
var viewEngine = viewResult.ViewEngine ?? ViewEngine;
|
||||||
var viewName = viewResult.ViewName ?? actionContext.ActionDescriptor.Name;
|
|
||||||
|
var viewName = viewResult.ViewName ?? GetActionName(actionContext);
|
||||||
|
|
||||||
var result = viewEngine.GetView(executingFilePath: null, viewPath: viewName, isMainPage: true);
|
var result = viewEngine.GetView(executingFilePath: null, viewPath: viewName, isMainPage: true);
|
||||||
var originalResult = result;
|
var originalResult = result;
|
||||||
|
|
@ -170,5 +174,47 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
|
||||||
viewResult.ContentType,
|
viewResult.ContentType,
|
||||||
viewResult.StatusCode);
|
viewResult.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetActionName(ActionContext context)
|
||||||
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
object routeValue;
|
||||||
|
if (!context.RouteData.Values.TryGetValue(ActionNameKey, out routeValue))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var actionDescriptor = context.ActionDescriptor;
|
||||||
|
string normalizedValue = null;
|
||||||
|
if (actionDescriptor.AttributeRouteInfo != null)
|
||||||
|
{
|
||||||
|
object match;
|
||||||
|
if (actionDescriptor.RouteValueDefaults.TryGetValue(ActionNameKey, out match))
|
||||||
|
{
|
||||||
|
normalizedValue = match?.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string value;
|
||||||
|
if (actionDescriptor.RouteValues.TryGetValue(ActionNameKey, out value) &&
|
||||||
|
!string.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
|
normalizedValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var stringRouteValue = routeValue?.ToString();
|
||||||
|
if (string.Equals(normalizedValue, stringRouteValue, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return normalizedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return stringRouteValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
|
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
|
||||||
|
|
@ -24,7 +25,7 @@ namespace Microsoft.AspNetCore.Mvc
|
||||||
/// Gets or sets the name of the partial view to render.
|
/// Gets or sets the name of the partial view to render.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// When <c>null</c>, defaults to <see cref="Abstractions.ActionDescriptor.Name"/>.
|
/// When <c>null</c>, defaults to <see cref="ControllerActionDescriptor.ActionName"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public string ViewName { get; set; }
|
public string ViewName { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
|
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
|
||||||
|
|
@ -24,7 +25,7 @@ namespace Microsoft.AspNetCore.Mvc
|
||||||
/// Gets or sets the name of the view to render.
|
/// Gets or sets the name of the view to render.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// When <c>null</c>, defaults to <see cref="Abstractions.ActionDescriptor.Name"/>.
|
/// When <c>null</c>, defaults to <see cref="ControllerActionDescriptor.ActionName"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public string ViewName { get; set; }
|
public string ViewName { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -398,7 +398,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
|
||||||
var result = InvokeActionSelector(routeContext);
|
var result = InvokeActionSelector(routeContext);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal("Patch", result.Name);
|
Assert.Equal("Patch", result.ActionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
|
@ -419,7 +419,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
|
||||||
var result = InvokeActionSelector(routeContext);
|
var result = InvokeActionSelector(routeContext);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal("Put", result.Name);
|
Assert.Equal("Put", result.ActionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
|
@ -451,7 +451,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
|
||||||
// Act
|
// Act
|
||||||
var result = actionDescriptorProvider
|
var result = actionDescriptorProvider
|
||||||
.GetDescriptors()
|
.GetDescriptors()
|
||||||
.FirstOrDefault(x => x.ControllerName == "NonAction" && x.Name == actionName);
|
.FirstOrDefault(x => x.ControllerName == "NonAction" && x.ActionName == actionName);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Null(result);
|
Assert.Null(result);
|
||||||
|
|
@ -504,10 +504,10 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
|
||||||
var result = InvokeActionSelector(routeContext);
|
var result = InvokeActionSelector(routeContext);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(actionName, result.Name);
|
Assert.Equal(actionName, result.ActionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActionDescriptor InvokeActionSelector(RouteContext context)
|
private ControllerActionDescriptor InvokeActionSelector(RouteContext context)
|
||||||
{
|
{
|
||||||
var actionDescriptorProvider = GetActionDescriptorProvider();
|
var actionDescriptorProvider = GetActionDescriptorProvider();
|
||||||
|
|
||||||
|
|
@ -533,7 +533,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
|
||||||
GetActionConstraintCache(actionConstraintProviders),
|
GetActionConstraintCache(actionConstraintProviders),
|
||||||
NullLoggerFactory.Instance);
|
NullLoggerFactory.Instance);
|
||||||
|
|
||||||
return defaultActionSelector.Select(context);
|
return (ControllerActionDescriptor)defaultActionSelector.Select(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ControllerActionDescriptorProvider GetActionDescriptorProvider()
|
private ControllerActionDescriptorProvider GetActionDescriptorProvider()
|
||||||
|
|
@ -664,9 +664,9 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
|
||||||
|
|
||||||
private static ActionDescriptor CreateAction(string area, string controller, string action)
|
private static ActionDescriptor CreateAction(string area, string controller, string action)
|
||||||
{
|
{
|
||||||
var actionDescriptor = new ActionDescriptor()
|
var actionDescriptor = new ControllerActionDescriptor()
|
||||||
{
|
{
|
||||||
Name = string.Format("Area: {0}, Controller: {1}, Action: {2}", area, controller, action),
|
ActionName = string.Format("Area: {0}, Controller: {1}, Action: {2}", area, controller, action),
|
||||||
Parameters = new List<ParameterDescriptor>(),
|
Parameters = new List<ParameterDescriptor>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var descriptors = provider.GetDescriptors();
|
var descriptors = provider.GetDescriptors();
|
||||||
var actionNames = descriptors.Select(ad => ad.Name);
|
var actionNames = descriptors.Select(ad => ad.ActionName);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(new[] { "GetPerson", "ShowPeople", }, actionNames);
|
Assert.Equal(new[] { "GetPerson", "ShowPeople", }, actionNames);
|
||||||
|
|
@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var descriptors = provider.GetDescriptors();
|
var descriptors = provider.GetDescriptors();
|
||||||
var descriptor = descriptors.Single(ad => ad.Name == nameof(PersonController.GetPerson));
|
var descriptor = descriptors.Single(ad => ad.ActionName == nameof(PersonController.GetPerson));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal($"{controllerTypeInfo.FullName}.{nameof(PersonController.GetPerson)} ({controllerTypeInfo.Assembly.GetName().Name})", descriptor.DisplayName);
|
Assert.Equal($"{controllerTypeInfo.FullName}.{nameof(PersonController.GetPerson)} ({controllerTypeInfo.Assembly.GetName().Name})", descriptor.DisplayName);
|
||||||
|
|
@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
var descriptor = Assert.Single(descriptors);
|
var descriptor = Assert.Single(descriptors);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal("OnlyPost", descriptor.Name);
|
Assert.Equal("OnlyPost", descriptor.ActionName);
|
||||||
|
|
||||||
var constraint = Assert.IsType<HttpMethodActionConstraint>(Assert.Single(descriptor.ActionConstraints));
|
var constraint = Assert.IsType<HttpMethodActionConstraint>(Assert.Single(descriptor.ActionConstraints));
|
||||||
Assert.Equal(new string[] { "POST" }, constraint.HttpMethods);
|
Assert.Equal(new string[] { "POST" }, constraint.HttpMethods);
|
||||||
|
|
@ -123,8 +123,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
typeof(ActionParametersController).GetTypeInfo());
|
typeof(ActionParametersController).GetTypeInfo());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var main = Assert.Single(descriptors,
|
var main = Assert.Single(descriptors.Cast<ControllerActionDescriptor>(),
|
||||||
d => d.Name.Equals(nameof(ActionParametersController.RequiredInt)));
|
d => d.ActionName.Equals(nameof(ActionParametersController.RequiredInt)));
|
||||||
|
|
||||||
Assert.NotNull(main.Parameters);
|
Assert.NotNull(main.Parameters);
|
||||||
var id = Assert.Single(main.Parameters);
|
var id = Assert.Single(main.Parameters);
|
||||||
|
|
@ -142,8 +142,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
typeof(ActionParametersController).GetTypeInfo());
|
typeof(ActionParametersController).GetTypeInfo());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var main = Assert.Single(descriptors,
|
var main = Assert.Single(descriptors.Cast<ControllerActionDescriptor>(),
|
||||||
d => d.Name.Equals(nameof(ActionParametersController.MultipleParameters)));
|
d => d.ActionName.Equals(nameof(ActionParametersController.MultipleParameters)));
|
||||||
|
|
||||||
Assert.NotNull(main.Parameters);
|
Assert.NotNull(main.Parameters);
|
||||||
var id = Assert.Single(main.Parameters, p => p.Name == "id");
|
var id = Assert.Single(main.Parameters, p => p.Name == "id");
|
||||||
|
|
@ -167,8 +167,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
typeof(ActionParametersController).GetTypeInfo());
|
typeof(ActionParametersController).GetTypeInfo());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var main = Assert.Single(descriptors,
|
var main = Assert.Single(descriptors.Cast<ControllerActionDescriptor>(),
|
||||||
d => d.Name.Equals(nameof(ActionParametersController.DifferentCasing)));
|
d => d.ActionName.Equals(nameof(ActionParametersController.DifferentCasing)));
|
||||||
|
|
||||||
Assert.NotNull(main.Parameters);
|
Assert.NotNull(main.Parameters);
|
||||||
var id = Assert.Single(main.Parameters, p => p.Name == "id");
|
var id = Assert.Single(main.Parameters, p => p.Name == "id");
|
||||||
|
|
@ -200,8 +200,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
typeof(ActionParametersController).GetTypeInfo());
|
typeof(ActionParametersController).GetTypeInfo());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var fromBody = Assert.Single(descriptors,
|
var fromBody = Assert.Single(descriptors.Cast<ControllerActionDescriptor>(),
|
||||||
d => d.Name.Equals(actionName));
|
d => d.ActionName.Equals(actionName));
|
||||||
|
|
||||||
Assert.NotNull(fromBody.Parameters);
|
Assert.NotNull(fromBody.Parameters);
|
||||||
var entity = Assert.Single(fromBody.Parameters);
|
var entity = Assert.Single(fromBody.Parameters);
|
||||||
|
|
@ -221,8 +221,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
typeof(ActionParametersController).GetTypeInfo());
|
typeof(ActionParametersController).GetTypeInfo());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var notFromBody = Assert.Single(descriptors,
|
var notFromBody = Assert.Single(descriptors.Cast<ControllerActionDescriptor>(),
|
||||||
d => d.Name.Equals(actionName));
|
d => d.ActionName.Equals(actionName));
|
||||||
|
|
||||||
Assert.NotNull(notFromBody.Parameters);
|
Assert.NotNull(notFromBody.Parameters);
|
||||||
var entity = Assert.Single(notFromBody.Parameters);
|
var entity = Assert.Single(notFromBody.Parameters);
|
||||||
|
|
@ -470,12 +470,12 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
var descriptors = provider.GetDescriptors();
|
var descriptors = provider.GetDescriptors();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var actions = descriptors.Where(d => d.Name == "MultipleHttpGet");
|
var actions = descriptors.Where(d => d.ActionName == "MultipleHttpGet");
|
||||||
Assert.Equal(4, actions.Count());
|
Assert.Equal(4, actions.Count());
|
||||||
|
|
||||||
foreach (var action in actions)
|
foreach (var action in actions)
|
||||||
{
|
{
|
||||||
Assert.Equal("MultipleHttpGet", action.Name);
|
Assert.Equal("MultipleHttpGet", action.ActionName);
|
||||||
Assert.Equal("MultiRouteAttributes", action.ControllerName);
|
Assert.Equal("MultiRouteAttributes", action.ControllerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -495,7 +495,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
var descriptors = provider.GetDescriptors();
|
var descriptors = provider.GetDescriptors();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var actions = descriptors.Where(d => d.Name == nameof(MultiRouteAttributesController.AcceptVerbs));
|
var actions = descriptors.Where(d => d.ActionName == nameof(MultiRouteAttributesController.AcceptVerbs));
|
||||||
Assert.Equal(2, actions.Count());
|
Assert.Equal(2, actions.Count());
|
||||||
|
|
||||||
foreach (var action in actions)
|
foreach (var action in actions)
|
||||||
|
|
@ -523,7 +523,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
var descriptors = provider.GetDescriptors();
|
var descriptors = provider.GetDescriptors();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var action = Assert.Single(descriptors, d => d.Name == "AcceptVerbsOverride");
|
var action = Assert.Single(descriptors, d => d.ActionName == "AcceptVerbsOverride");
|
||||||
|
|
||||||
Assert.Equal("MultiRouteAttributes", action.ControllerName);
|
Assert.Equal("MultiRouteAttributes", action.ControllerName);
|
||||||
|
|
||||||
|
|
@ -547,7 +547,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
var descriptors = provider.GetDescriptors();
|
var descriptors = provider.GetDescriptors();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var actions = descriptors.Where(d => d.Name == "AcceptVerbsRouteAttributeAndHttpPut");
|
var actions = descriptors.Where(d => d.ActionName == "AcceptVerbsRouteAttributeAndHttpPut");
|
||||||
Assert.Equal(4, actions.Count());
|
Assert.Equal(4, actions.Count());
|
||||||
|
|
||||||
foreach (var action in actions)
|
foreach (var action in actions)
|
||||||
|
|
@ -586,7 +586,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
var descriptors = provider.GetDescriptors();
|
var descriptors = provider.GetDescriptors();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var actions = descriptors.Where(d => d.Name == "AcceptVerbsRouteAttributeWithTemplateAndHttpPut");
|
var actions = descriptors.Where(d => d.ActionName == "AcceptVerbsRouteAttributeWithTemplateAndHttpPut");
|
||||||
Assert.Equal(6, actions.Count());
|
Assert.Equal(6, actions.Count());
|
||||||
|
|
||||||
foreach (var action in actions)
|
foreach (var action in actions)
|
||||||
|
|
@ -633,10 +633,10 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
var actions = provider.GetDescriptors();
|
var actions = provider.GetDescriptors();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var controllerAndAction = Assert.Single(actions, a => a.Name.Equals(firstActionName));
|
var controllerAndAction = Assert.Single(actions, a => a.ActionName.Equals(firstActionName));
|
||||||
Assert.NotNull(controllerAndAction.AttributeRouteInfo);
|
Assert.NotNull(controllerAndAction.AttributeRouteInfo);
|
||||||
|
|
||||||
var controllerActionAndOverride = Assert.Single(actions, a => a.Name.Equals(secondActionName));
|
var controllerActionAndOverride = Assert.Single(actions, a => a.ActionName.Equals(secondActionName));
|
||||||
Assert.NotNull(controllerActionAndOverride.AttributeRouteInfo);
|
Assert.NotNull(controllerActionAndOverride.AttributeRouteInfo);
|
||||||
|
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
|
|
@ -656,7 +656,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
var descriptors = provider.GetDescriptors();
|
var descriptors = provider.GetDescriptors();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var actions = descriptors.Where(d => d.Name.Equals(actionName));
|
var actions = descriptors.Where(d => d.ActionName.Equals(actionName));
|
||||||
Assert.Equal(5, actions.Count());
|
Assert.Equal(5, actions.Count());
|
||||||
|
|
||||||
foreach (var method in new[] { "GET", "POST", "PUT", "PATCH", "DELETE" })
|
foreach (var method in new[] { "GET", "POST", "PUT", "PATCH", "DELETE" })
|
||||||
|
|
@ -759,7 +759,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
// Assert
|
// Assert
|
||||||
var action = Assert.Single(actions);
|
var action = Assert.Single(actions);
|
||||||
|
|
||||||
Assert.Equal("Action", action.Name);
|
Assert.Equal("Action", action.ActionName);
|
||||||
Assert.Equal("OnlyRoute", action.ControllerName);
|
Assert.Equal("OnlyRoute", action.ControllerName);
|
||||||
|
|
||||||
Assert.NotNull(action.AttributeRouteInfo);
|
Assert.NotNull(action.AttributeRouteInfo);
|
||||||
|
|
@ -842,7 +842,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
var actions = provider.GetDescriptors();
|
var actions = provider.GetDescriptors();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var getActions = actions.Where(a => a.Name.Equals(getActionName));
|
var getActions = actions.Where(a => a.ActionName.Equals(getActionName));
|
||||||
Assert.Equal(2, getActions.Count());
|
Assert.Equal(2, getActions.Count());
|
||||||
|
|
||||||
foreach (var getAction in getActions)
|
foreach (var getAction in getActions)
|
||||||
|
|
@ -852,7 +852,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
Assert.Equal("Products_Get", getAction.AttributeRouteInfo.Name, StringComparer.OrdinalIgnoreCase);
|
Assert.Equal("Products_Get", getAction.AttributeRouteInfo.Name, StringComparer.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
var editAction = Assert.Single(actions, a => a.Name.Equals(editActionName));
|
var editAction = Assert.Single(actions, a => a.ActionName.Equals(editActionName));
|
||||||
Assert.NotNull(editAction.AttributeRouteInfo);
|
Assert.NotNull(editAction.AttributeRouteInfo);
|
||||||
Assert.Equal("Products/Edit", editAction.AttributeRouteInfo.Template, StringComparer.OrdinalIgnoreCase);
|
Assert.Equal("Products/Edit", editAction.AttributeRouteInfo.Template, StringComparer.OrdinalIgnoreCase);
|
||||||
Assert.Equal("Products_Edit", editAction.AttributeRouteInfo.Name, StringComparer.OrdinalIgnoreCase);
|
Assert.Equal("Products_Edit", editAction.AttributeRouteInfo.Name, StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
@ -870,7 +870,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
var actions = provider.GetDescriptors();
|
var actions = provider.GetDescriptors();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var getActions = actions.Where(a => a.Name.Equals(getActionName));
|
var getActions = actions.Where(a => a.ActionName.Equals(getActionName));
|
||||||
Assert.Equal(2, getActions.Count());
|
Assert.Equal(2, getActions.Count());
|
||||||
|
|
||||||
foreach (var getAction in getActions)
|
foreach (var getAction in getActions)
|
||||||
|
|
@ -884,7 +884,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
getAction.AttributeRouteInfo.Name, StringComparer.OrdinalIgnoreCase);
|
getAction.AttributeRouteInfo.Name, StringComparer.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
var editAction = Assert.Single(actions, a => a.Name.Equals(editActionName));
|
var editAction = Assert.Single(actions, a => a.ActionName.Equals(editActionName));
|
||||||
Assert.NotNull(editAction.AttributeRouteInfo);
|
Assert.NotNull(editAction.AttributeRouteInfo);
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
"ControllerActionRouteNameTemplates/Edit",
|
"ControllerActionRouteNameTemplates/Edit",
|
||||||
|
|
@ -955,7 +955,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
Assert.NotNull(actionDescriptors);
|
Assert.NotNull(actionDescriptors);
|
||||||
Assert.Equal(4, actionDescriptors.Count());
|
Assert.Equal(4, actionDescriptors.Count());
|
||||||
|
|
||||||
var indexAction = Assert.Single(actionDescriptors, ad => ad.Name.Equals("Index"));
|
var indexAction = Assert.Single(actionDescriptors, ad => ad.ActionName.Equals("Index"));
|
||||||
|
|
||||||
Assert.Equal(1, indexAction.RouteValues.Count);
|
Assert.Equal(1, indexAction.RouteValues.Count);
|
||||||
|
|
||||||
|
|
@ -1058,10 +1058,10 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(2, actions.Count());
|
Assert.Equal(2, actions.Count());
|
||||||
|
|
||||||
var action = Assert.Single(actions, a => a.Name == "Edit");
|
var action = Assert.Single(actions, a => a.ActionName == "Edit");
|
||||||
Assert.NotNull(action.GetProperty<ApiDescriptionActionData>());
|
Assert.NotNull(action.GetProperty<ApiDescriptionActionData>());
|
||||||
|
|
||||||
action = Assert.Single(actions, a => a.Name == "Create");
|
action = Assert.Single(actions, a => a.ActionName == "Create");
|
||||||
Assert.Null(action.GetProperty<ApiDescriptionActionData>());
|
Assert.Null(action.GetProperty<ApiDescriptionActionData>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1138,10 +1138,10 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(2, actions.Count());
|
Assert.Equal(2, actions.Count());
|
||||||
|
|
||||||
var action = Assert.Single(actions, a => a.Name == "Edit");
|
var action = Assert.Single(actions, a => a.ActionName == "Edit");
|
||||||
Assert.Equal("Blog", action.GetProperty<ApiDescriptionActionData>().GroupName);
|
Assert.Equal("Blog", action.GetProperty<ApiDescriptionActionData>().GroupName);
|
||||||
|
|
||||||
action = Assert.Single(actions, a => a.Name == "Create");
|
action = Assert.Single(actions, a => a.ActionName == "Create");
|
||||||
Assert.Equal("Store", action.GetProperty<ApiDescriptionActionData>().GroupName);
|
Assert.Equal("Store", action.GetProperty<ApiDescriptionActionData>().GroupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1331,7 +1331,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
var provider = GetProvider(typeof(MultipleRouteProviderOnActionAndControllerController).GetTypeInfo());
|
var provider = GetProvider(typeof(MultipleRouteProviderOnActionAndControllerController).GetTypeInfo());
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var actions = provider.GetDescriptors().Where(a => a.Name == actionName);
|
var actions = provider.GetDescriptors().Where(a => a.ActionName == actionName);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(2, actions.Count());
|
Assert.Equal(2, actions.Count());
|
||||||
|
|
@ -1358,7 +1358,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
var provider = GetProvider(typeof(MultipleRouteProviderOnActionAndControllerController).GetTypeInfo());
|
var provider = GetProvider(typeof(MultipleRouteProviderOnActionAndControllerController).GetTypeInfo());
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var actions = provider.GetDescriptors().Where(a => a.Name == actionName);
|
var actions = provider.GetDescriptors().Where(a => a.ActionName == actionName);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(4, actions.Count());
|
Assert.Equal(4, actions.Count());
|
||||||
|
|
@ -1397,7 +1397,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
var provider = GetProvider(typeof(MultipleRouteProviderOnActionAndControllerController).GetTypeInfo());
|
var provider = GetProvider(typeof(MultipleRouteProviderOnActionAndControllerController).GetTypeInfo());
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var actions = provider.GetDescriptors().Where(a => a.Name == actionName);
|
var actions = provider.GetDescriptors().Where(a => a.ActionName == actionName);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(1, actions.Count());
|
Assert.Equal(1, actions.Count());
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||||
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||||
using Microsoft.AspNetCore.Mvc.Internal;
|
using Microsoft.AspNetCore.Mvc.Internal;
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
|
|
@ -184,9 +185,9 @@ namespace Microsoft.AspNetCore.Mvc.Routing
|
||||||
|
|
||||||
private static ActionDescriptor CreateActionDescriptor(string area, string controller, string action)
|
private static ActionDescriptor CreateActionDescriptor(string area, string controller, string action)
|
||||||
{
|
{
|
||||||
var actionDescriptor = new ActionDescriptor()
|
var actionDescriptor = new ControllerActionDescriptor()
|
||||||
{
|
{
|
||||||
Name = string.Format("Area: {0}, Controller: {1}, Action: {2}", area, controller, action),
|
ActionName = string.Format("Area: {0}, Controller: {1}, Action: {2}", area, controller, action),
|
||||||
};
|
};
|
||||||
|
|
||||||
actionDescriptor.RouteValues.Add("area", area);
|
actionDescriptor.RouteValues.Add("area", area);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||||
using Microsoft.AspNetCore.Mvc.Formatters;
|
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
||||||
|
|
@ -57,11 +58,9 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
|
||||||
public void FindView_UsesActionDescriptorName_IfViewNameIsNull()
|
public void FindView_UsesActionDescriptorName_IfViewNameIsNull()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var context = GetActionContext();
|
|
||||||
var executor = GetViewExecutor();
|
|
||||||
|
|
||||||
var viewName = "some-view-name";
|
var viewName = "some-view-name";
|
||||||
context.ActionDescriptor.Name = viewName;
|
var context = GetActionContext(viewName);
|
||||||
|
var executor = GetViewExecutor();
|
||||||
|
|
||||||
var viewResult = new PartialViewResult
|
var viewResult = new PartialViewResult
|
||||||
{
|
{
|
||||||
|
|
@ -309,9 +308,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
|
||||||
Assert.Equal(404, context.HttpContext.Response.StatusCode);
|
Assert.Equal(404, context.HttpContext.Response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActionContext GetActionContext()
|
private ActionContext GetActionContext(string actionName = null)
|
||||||
{
|
{
|
||||||
return new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());
|
var routeData = new RouteData();
|
||||||
|
routeData.Values["action"] = actionName;
|
||||||
|
|
||||||
|
return new ActionContext(new DefaultHttpContext(), routeData, new ControllerActionDescriptor() { ActionName = actionName });
|
||||||
}
|
}
|
||||||
|
|
||||||
private PartialViewResultExecutor GetViewExecutor(DiagnosticSource diagnosticSource = null)
|
private PartialViewResultExecutor GetViewExecutor(DiagnosticSource diagnosticSource = null)
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
|
|
@ -56,11 +57,9 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
|
||||||
public void FindView_UsesActionDescriptorName_IfViewNameIsNull()
|
public void FindView_UsesActionDescriptorName_IfViewNameIsNull()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var context = GetActionContext();
|
|
||||||
var executor = GetViewExecutor();
|
|
||||||
|
|
||||||
var viewName = "some-view-name";
|
var viewName = "some-view-name";
|
||||||
context.ActionDescriptor.Name = viewName;
|
var context = GetActionContext(viewName);
|
||||||
|
var executor = GetViewExecutor();
|
||||||
|
|
||||||
var viewResult = new ViewResult
|
var viewResult = new ViewResult
|
||||||
{
|
{
|
||||||
|
|
@ -299,9 +298,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
|
||||||
Assert.Equal(404, context.HttpContext.Response.StatusCode);
|
Assert.Equal(404, context.HttpContext.Response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActionContext GetActionContext()
|
private ActionContext GetActionContext(string actionName = null)
|
||||||
{
|
{
|
||||||
return new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());
|
var routeData = new RouteData();
|
||||||
|
routeData.Values["action"] = actionName;
|
||||||
|
|
||||||
|
return new ActionContext(new DefaultHttpContext(), routeData, new ControllerActionDescriptor() { ActionName = actionName });
|
||||||
}
|
}
|
||||||
|
|
||||||
private ViewResultExecutor GetViewExecutor(DiagnosticListener diagnosticSource = null)
|
private ViewResultExecutor GetViewExecutor(DiagnosticListener diagnosticSource = null)
|
||||||
|
|
|
||||||
|
|
@ -272,7 +272,7 @@ namespace System.Web.Http
|
||||||
var controllerType = typeof(TestControllers.EmployeesController).GetTypeInfo();
|
var controllerType = typeof(TestControllers.EmployeesController).GetTypeInfo();
|
||||||
var actions = results
|
var actions = results
|
||||||
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
||||||
.Where(ad => ad.Name == "Get")
|
.Where(ad => ad.ActionName == "Get")
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
Assert.NotEmpty(actions);
|
Assert.NotEmpty(actions);
|
||||||
|
|
@ -301,7 +301,7 @@ namespace System.Web.Http
|
||||||
var controllerType = typeof(TestControllers.EmployeesController).GetTypeInfo();
|
var controllerType = typeof(TestControllers.EmployeesController).GetTypeInfo();
|
||||||
var actions = results
|
var actions = results
|
||||||
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
||||||
.Where(ad => ad.Name == "Put")
|
.Where(ad => ad.ActionName == "Put")
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
Assert.NotEmpty(actions);
|
Assert.NotEmpty(actions);
|
||||||
|
|
@ -328,7 +328,7 @@ namespace System.Web.Http
|
||||||
var controllerType = typeof(TestControllers.EmployeesController).GetTypeInfo();
|
var controllerType = typeof(TestControllers.EmployeesController).GetTypeInfo();
|
||||||
var actions = results
|
var actions = results
|
||||||
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
||||||
.Where(ad => ad.Name == "Post")
|
.Where(ad => ad.ActionName == "Post")
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
Assert.NotEmpty(actions);
|
Assert.NotEmpty(actions);
|
||||||
|
|
@ -357,7 +357,7 @@ namespace System.Web.Http
|
||||||
var controllerType = typeof(TestControllers.EventsController).GetTypeInfo();
|
var controllerType = typeof(TestControllers.EventsController).GetTypeInfo();
|
||||||
var actions = results
|
var actions = results
|
||||||
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
.Where(ad => ad.ControllerTypeInfo == controllerType)
|
||||||
.Where(ad => ad.Name == name)
|
.Where(ad => ad.ActionName == name)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
Assert.NotEmpty(actions);
|
Assert.NotEmpty(actions);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace ApplicationModelWebSite
|
||||||
[ActionName2("ActionName")]
|
[ActionName2("ActionName")]
|
||||||
public string GetActionName()
|
public string GetActionName()
|
||||||
{
|
{
|
||||||
return ControllerContext.ActionDescriptor.Name;
|
return ControllerContext.ActionDescriptor.ActionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ActionName2Attribute : Attribute, IActionModelConvention
|
private class ActionName2Attribute : Attribute, IActionModelConvention
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
|
||||||
namespace BasicWebSite
|
namespace BasicWebSite
|
||||||
|
|
@ -29,7 +30,7 @@ namespace BasicWebSite
|
||||||
{
|
{
|
||||||
if (!context.RouteData.DataTokens.ContainsKey("actionName"))
|
if (!context.RouteData.DataTokens.ContainsKey("actionName"))
|
||||||
{
|
{
|
||||||
context.RouteData.DataTokens.Add("actionName", context.ActionDescriptor.Name);
|
context.RouteData.DataTokens.Add("actionName", ((ControllerActionDescriptor)context.ActionDescriptor).ActionName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||||
|
|
||||||
|
|
@ -27,7 +28,7 @@ namespace FormatterWebSite
|
||||||
{
|
{
|
||||||
var errorInfo = new ErrorInfo
|
var errorInfo = new ErrorInfo
|
||||||
{
|
{
|
||||||
ActionName = context.ActionDescriptor.Name,
|
ActionName = ((ControllerActionDescriptor)context.ActionDescriptor).ActionName,
|
||||||
ParameterName = bodyParameter.Name,
|
ParameterName = bodyParameter.Name,
|
||||||
Errors = parameterBindingErrors.Select(x => x.ErrorMessage).ToList(),
|
Errors = parameterBindingErrors.Select(x => x.ErrorMessage).ToList(),
|
||||||
Source = "filter"
|
Source = "filter"
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ namespace RoutingWebSite
|
||||||
routeName = attributeRoutingInfo == null ? null : attributeRoutingInfo.Name,
|
routeName = attributeRoutingInfo == null ? null : attributeRoutingInfo.Name,
|
||||||
routeValues = new Dictionary<string, object>(_actionContext.RouteData.Values),
|
routeValues = new Dictionary<string, object>(_actionContext.RouteData.Values),
|
||||||
|
|
||||||
action = _actionContext.ActionDescriptor.Name,
|
action = ((ControllerActionDescriptor) _actionContext.ActionDescriptor).ActionName,
|
||||||
controller = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ControllerName,
|
controller = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ControllerName,
|
||||||
|
|
||||||
link,
|
link,
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ namespace VersioningWebSite
|
||||||
routeName = attributeRoutingInfo == null ? null : attributeRoutingInfo.Name,
|
routeName = attributeRoutingInfo == null ? null : attributeRoutingInfo.Name,
|
||||||
routeValues = new Dictionary<string, object>(_actionContext.RouteData.Values),
|
routeValues = new Dictionary<string, object>(_actionContext.RouteData.Values),
|
||||||
|
|
||||||
action = _actionContext.ActionDescriptor.Name,
|
action = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ActionName,
|
||||||
controller = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ControllerName,
|
controller = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ControllerName,
|
||||||
|
|
||||||
link,
|
link,
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ namespace WebApiCompatShimWebSite
|
||||||
{
|
{
|
||||||
JsonConvert.SerializeObject(new
|
JsonConvert.SerializeObject(new
|
||||||
{
|
{
|
||||||
ActionName = action.Name,
|
ActionName = action.ActionName,
|
||||||
ControllerName = action.ControllerName
|
ControllerName = action.ControllerName
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue