diff --git a/src/Microsoft.AspNetCore.Mvc.Abstractions/Abstractions/ActionDescriptor.cs b/src/Microsoft.AspNetCore.Mvc.Abstractions/Abstractions/ActionDescriptor.cs
index be416aa30b..edd4bee4e2 100644
--- a/src/Microsoft.AspNetCore.Mvc.Abstractions/Abstractions/ActionDescriptor.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Abstractions/Abstractions/ActionDescriptor.cs
@@ -22,9 +22,7 @@ public ActionDescriptor()
///
/// Gets an id which uniquely identifies the action.
///
- public string Id { get; }
-
- public virtual string Name { get; set; }
+ public string Id { get; }
///
/// Gets or sets the collection of route values that must be provided by routing
diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Controllers/ControllerActionDescriptor.cs b/src/Microsoft.AspNetCore.Mvc.Core/Controllers/ControllerActionDescriptor.cs
index 7b5ffa5b81..7292139d1a 100644
--- a/src/Microsoft.AspNetCore.Mvc.Core/Controllers/ControllerActionDescriptor.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Core/Controllers/ControllerActionDescriptor.cs
@@ -14,6 +14,8 @@ public class ControllerActionDescriptor : ActionDescriptor
{
public string ControllerName { get; set; }
+ public virtual string ActionName { get; set; }
+
public MethodInfo MethodInfo { get; set; }
public TypeInfo ControllerTypeInfo { get; set; }
diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionDescriptorBuilder.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionDescriptorBuilder.cs
index 9c504aa22c..0d3c8a790d 100644
--- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionDescriptorBuilder.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionDescriptorBuilder.cs
@@ -282,7 +282,7 @@ private static ControllerActionDescriptor CreateActionDescriptor(
var actionDescriptor = new ControllerActionDescriptor()
{
- Name = action.ActionName,
+ ActionName = action.ActionName,
MethodInfo = action.ActionMethod,
Parameters = parameterDescriptors,
AttributeRouteInfo = CreateAttributeRouteInfo(actionAttributeRoute, controllerAttributeRoute)
diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Routing/IRouteValueProvider.cs b/src/Microsoft.AspNetCore.Mvc.Core/Routing/IRouteValueProvider.cs
index 9917c825f2..b71117f870 100644
--- a/src/Microsoft.AspNetCore.Mvc.Core/Routing/IRouteValueProvider.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Core/Routing/IRouteValueProvider.cs
@@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Mvc.Routing
///
/// The typical scheme for action selection in an MVC application is that an action will require the
/// matching values for its and
- ///
+ ///
///
///
/// For an action like MyApp.Controllers.HomeController.Index()
, in order to be selected, the
diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/PartialViewResultExecutor.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/PartialViewResultExecutor.cs
index bef07fccad..51bc8636af 100644
--- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/PartialViewResultExecutor.cs
+++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/PartialViewResultExecutor.cs
@@ -6,6 +6,7 @@
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
@@ -69,7 +70,7 @@ public virtual ViewEngineResult FindView(ActionContext actionContext, PartialVie
}
var viewEngine = viewResult.ViewEngine ?? ViewEngine;
- var viewName = viewResult.ViewName ?? actionContext.ActionDescriptor.Name;
+ var viewName = viewResult.ViewName ?? (actionContext.ActionDescriptor as ControllerActionDescriptor)?.ActionName;
var result = viewEngine.GetView(executingFilePath: null, viewPath: viewName, isMainPage: false);
var originalResult = result;
diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/ViewResultExecutor.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/ViewResultExecutor.cs
index 8ca83fe40f..ccb3e9cd2c 100644
--- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/ViewResultExecutor.cs
+++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/ViewResultExecutor.cs
@@ -6,6 +6,7 @@
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
@@ -69,7 +70,8 @@ public virtual ViewEngineResult FindView(ActionContext actionContext, ViewResult
}
var viewEngine = viewResult.ViewEngine ?? ViewEngine;
- var viewName = viewResult.ViewName ?? actionContext.ActionDescriptor.Name;
+
+ var viewName = viewResult.ViewName ?? (actionContext.ActionDescriptor as ControllerActionDescriptor)?.ActionName;
var result = viewEngine.GetView(executingFilePath: null, viewPath: viewName, isMainPage: true);
var originalResult = result;
diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/PartialViewResult.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/PartialViewResult.cs
index afa44e1a8b..7abf63632e 100644
--- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/PartialViewResult.cs
+++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/PartialViewResult.cs
@@ -3,6 +3,7 @@
using System;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
@@ -24,7 +25,7 @@ public class PartialViewResult : ActionResult
/// Gets or sets the name of the partial view to render.
///
///
- /// When null, defaults to .
+ /// When null, defaults to .
///
public string ViewName { get; set; }
diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewResult.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewResult.cs
index 14c9e1410a..bc43a62247 100644
--- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewResult.cs
+++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewResult.cs
@@ -3,6 +3,7 @@
using System;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
@@ -24,7 +25,7 @@ public class ViewResult : ActionResult
/// Gets or sets the name of the view to render.
///
///
- /// When null, defaults to .
+ /// When null, defaults to .
///
public string ViewName { get; set; }
diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Infrastructure/DefaultActionSelectorTests.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Infrastructure/DefaultActionSelectorTests.cs
index d540f14f6f..288c4a76c3 100644
--- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Infrastructure/DefaultActionSelectorTests.cs
+++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Infrastructure/DefaultActionSelectorTests.cs
@@ -398,7 +398,7 @@ public void HttpMethodAttribute_ActionWithMultipleHttpMethodAttributeViaAcceptVe
var result = InvokeActionSelector(routeContext);
// Assert
- Assert.Equal("Patch", result.Name);
+ Assert.Equal("Patch", result.ActionName);
}
[Theory]
@@ -419,7 +419,7 @@ public void HttpMethodAttribute_ActionWithMultipleHttpMethodAttributes_ORsMultip
var result = InvokeActionSelector(routeContext);
// Assert
- Assert.Equal("Put", result.Name);
+ Assert.Equal("Put", result.ActionName);
}
[Theory]
@@ -451,7 +451,7 @@ public void NonActionAttribute_ActionNotReachable(string actionName)
// Act
var result = actionDescriptorProvider
.GetDescriptors()
- .FirstOrDefault(x => x.ControllerName == "NonAction" && x.Name == actionName);
+ .FirstOrDefault(x => x.ControllerName == "NonAction" && x.ActionName == actionName);
// Assert
Assert.Null(result);
@@ -504,10 +504,10 @@ public void ActionNameAttribute_DifferentActionName_UsesActionNameFromActionName
var result = InvokeActionSelector(routeContext);
// Assert
- Assert.Equal(actionName, result.Name);
+ Assert.Equal(actionName, result.ActionName);
}
- private ActionDescriptor InvokeActionSelector(RouteContext context)
+ private ControllerActionDescriptor InvokeActionSelector(RouteContext context)
{
var actionDescriptorProvider = GetActionDescriptorProvider();
@@ -533,7 +533,7 @@ private ActionDescriptor InvokeActionSelector(RouteContext context)
GetActionConstraintCache(actionConstraintProviders),
NullLoggerFactory.Instance);
- return defaultActionSelector.Select(context);
+ return (ControllerActionDescriptor)defaultActionSelector.Select(context);
}
private ControllerActionDescriptorProvider GetActionDescriptorProvider()
@@ -664,9 +664,9 @@ private static RouteContext CreateRouteContext(string httpMethod)
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(),
};
diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionDescriptorProviderTests.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionDescriptorProviderTests.cs
index e49e1cb5e4..c63a98b9b0 100644
--- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionDescriptorProviderTests.cs
+++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionDescriptorProviderTests.cs
@@ -30,7 +30,7 @@ public void GetDescriptors_GetsDescriptorsOnlyForValidActions()
// Act
var descriptors = provider.GetDescriptors();
- var actionNames = descriptors.Select(ad => ad.Name);
+ var actionNames = descriptors.Select(ad => ad.ActionName);
// Assert
Assert.Equal(new[] { "GetPerson", "ShowPeople", }, actionNames);
@@ -45,7 +45,7 @@ public void GetDescriptors_DisplayNameIncludesAssemblyName()
// Act
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.Equal($"{controllerTypeInfo.FullName}.{nameof(PersonController.GetPerson)} ({controllerTypeInfo.Assembly.GetName().Name})", descriptor.DisplayName);
@@ -92,7 +92,7 @@ public void GetDescriptors_AddsHttpMethodConstraints_ForConventionallyRoutedActi
var descriptor = Assert.Single(descriptors);
// Assert
- Assert.Equal("OnlyPost", descriptor.Name);
+ Assert.Equal("OnlyPost", descriptor.ActionName);
var constraint = Assert.IsType(Assert.Single(descriptor.ActionConstraints));
Assert.Equal(new string[] { "POST" }, constraint.HttpMethods);
@@ -123,8 +123,8 @@ public void GetDescriptors_AddsParameters_ToActionDescriptor()
typeof(ActionParametersController).GetTypeInfo());
// Assert
- var main = Assert.Single(descriptors,
- d => d.Name.Equals(nameof(ActionParametersController.RequiredInt)));
+ var main = Assert.Single(descriptors.Cast(),
+ d => d.ActionName.Equals(nameof(ActionParametersController.RequiredInt)));
Assert.NotNull(main.Parameters);
var id = Assert.Single(main.Parameters);
@@ -142,8 +142,8 @@ public void GetDescriptors_AddsMultipleParameters_ToActionDescriptor()
typeof(ActionParametersController).GetTypeInfo());
// Assert
- var main = Assert.Single(descriptors,
- d => d.Name.Equals(nameof(ActionParametersController.MultipleParameters)));
+ var main = Assert.Single(descriptors.Cast(),
+ d => d.ActionName.Equals(nameof(ActionParametersController.MultipleParameters)));
Assert.NotNull(main.Parameters);
var id = Assert.Single(main.Parameters, p => p.Name == "id");
@@ -167,8 +167,8 @@ public void GetDescriptors_AddsMultipleParametersWithDifferentCasing_ToActionDes
typeof(ActionParametersController).GetTypeInfo());
// Assert
- var main = Assert.Single(descriptors,
- d => d.Name.Equals(nameof(ActionParametersController.DifferentCasing)));
+ var main = Assert.Single(descriptors.Cast(),
+ d => d.ActionName.Equals(nameof(ActionParametersController.DifferentCasing)));
Assert.NotNull(main.Parameters);
var id = Assert.Single(main.Parameters, p => p.Name == "id");
@@ -200,8 +200,8 @@ public void GetDescriptors_AddsParameters_DetectsFromBodyParameters()
typeof(ActionParametersController).GetTypeInfo());
// Assert
- var fromBody = Assert.Single(descriptors,
- d => d.Name.Equals(actionName));
+ var fromBody = Assert.Single(descriptors.Cast(),
+ d => d.ActionName.Equals(actionName));
Assert.NotNull(fromBody.Parameters);
var entity = Assert.Single(fromBody.Parameters);
@@ -221,8 +221,8 @@ public void GetDescriptors_AddsParameters_DoesNotDetectParameterFromBody_IfNoFro
typeof(ActionParametersController).GetTypeInfo());
// Assert
- var notFromBody = Assert.Single(descriptors,
- d => d.Name.Equals(actionName));
+ var notFromBody = Assert.Single(descriptors.Cast(),
+ d => d.ActionName.Equals(actionName));
Assert.NotNull(notFromBody.Parameters);
var entity = Assert.Single(notFromBody.Parameters);
@@ -470,12 +470,12 @@ public void AttributeRouting_CreatesOneActionDescriptor_PerControllerAndActionRo
var descriptors = provider.GetDescriptors();
// Assert
- var actions = descriptors.Where(d => d.Name == "MultipleHttpGet");
+ var actions = descriptors.Where(d => d.ActionName == "MultipleHttpGet");
Assert.Equal(4, actions.Count());
foreach (var action in actions)
{
- Assert.Equal("MultipleHttpGet", action.Name);
+ Assert.Equal("MultipleHttpGet", action.ActionName);
Assert.Equal("MultiRouteAttributes", action.ControllerName);
}
@@ -495,7 +495,7 @@ public void AttributeRouting_AcceptVerbsOnAction_CreatesActionPerControllerAttri
var descriptors = provider.GetDescriptors();
// 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());
foreach (var action in actions)
@@ -523,7 +523,7 @@ public void AttributeRouting_AcceptVerbsOnActionWithOverrideTemplate_CreatesSing
var descriptors = provider.GetDescriptors();
// Assert
- var action = Assert.Single(descriptors, d => d.Name == "AcceptVerbsOverride");
+ var action = Assert.Single(descriptors, d => d.ActionName == "AcceptVerbsOverride");
Assert.Equal("MultiRouteAttributes", action.ControllerName);
@@ -547,7 +547,7 @@ public void AttributeRouting_AcceptVerbsOnAction_WithoutTemplate_MergesVerb()
var descriptors = provider.GetDescriptors();
// Assert
- var actions = descriptors.Where(d => d.Name == "AcceptVerbsRouteAttributeAndHttpPut");
+ var actions = descriptors.Where(d => d.ActionName == "AcceptVerbsRouteAttributeAndHttpPut");
Assert.Equal(4, actions.Count());
foreach (var action in actions)
@@ -586,7 +586,7 @@ public void AttributeRouting_AcceptVerbsOnAction_WithTemplate_DoesNotMergeVerb()
var descriptors = provider.GetDescriptors();
// Assert
- var actions = descriptors.Where(d => d.Name == "AcceptVerbsRouteAttributeWithTemplateAndHttpPut");
+ var actions = descriptors.Where(d => d.ActionName == "AcceptVerbsRouteAttributeWithTemplateAndHttpPut");
Assert.Equal(6, actions.Count());
foreach (var action in actions)
@@ -633,10 +633,10 @@ public void AttributeRouting_AllowsDuplicateAttributeRoutedActions_WithTheSameTe
var actions = provider.GetDescriptors();
// 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);
- 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.Equal(
@@ -656,7 +656,7 @@ public void AttributeRouting_AllowsDuplicateAttributeRoutedActions_WithTheSameTe
var descriptors = provider.GetDescriptors();
// Assert
- var actions = descriptors.Where(d => d.Name.Equals(actionName));
+ var actions = descriptors.Where(d => d.ActionName.Equals(actionName));
Assert.Equal(5, actions.Count());
foreach (var method in new[] { "GET", "POST", "PUT", "PATCH", "DELETE" })
@@ -759,7 +759,7 @@ public void AttributeRouting_RouteOnControllerAndAction_CreatesActionDescriptorW
// Assert
var action = Assert.Single(actions);
- Assert.Equal("Action", action.Name);
+ Assert.Equal("Action", action.ActionName);
Assert.Equal("OnlyRoute", action.ControllerName);
Assert.NotNull(action.AttributeRouteInfo);
@@ -842,7 +842,7 @@ public void AttributeRouting_RouteNameTokenReplace_AllowsMultipleActions_WithSam
var actions = provider.GetDescriptors();
// Assert
- var getActions = actions.Where(a => a.Name.Equals(getActionName));
+ var getActions = actions.Where(a => a.ActionName.Equals(getActionName));
Assert.Equal(2, getActions.Count());
foreach (var getAction in getActions)
@@ -852,7 +852,7 @@ public void AttributeRouting_RouteNameTokenReplace_AllowsMultipleActions_WithSam
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.Equal("Products/Edit", editAction.AttributeRouteInfo.Template, StringComparer.OrdinalIgnoreCase);
Assert.Equal("Products_Edit", editAction.AttributeRouteInfo.Name, StringComparer.OrdinalIgnoreCase);
@@ -870,7 +870,7 @@ public void AttributeRouting_RouteNameTokenReplace_AreaControllerActionTokensInR
var actions = provider.GetDescriptors();
// Assert
- var getActions = actions.Where(a => a.Name.Equals(getActionName));
+ var getActions = actions.Where(a => a.ActionName.Equals(getActionName));
Assert.Equal(2, getActions.Count());
foreach (var getAction in getActions)
@@ -884,7 +884,7 @@ public void AttributeRouting_RouteNameTokenReplace_AreaControllerActionTokensInR
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.Equal(
"ControllerActionRouteNameTemplates/Edit",
@@ -955,7 +955,7 @@ public void AttributeRouting_AddsDefaultRouteValues_ForAttributeRoutedActions()
Assert.NotNull(actionDescriptors);
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);
@@ -1058,10 +1058,10 @@ public void ApiExplorer_SetsExtensionData_WhenVisible_CanOverrideControllerOnAct
// Assert
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());
- action = Assert.Single(actions, a => a.Name == "Create");
+ action = Assert.Single(actions, a => a.ActionName == "Create");
Assert.Null(action.GetProperty());
}
@@ -1138,10 +1138,10 @@ public void ApiExplorer_SetsName_CanOverrideControllerOnAction()
// Assert
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().GroupName);
- action = Assert.Single(actions, a => a.Name == "Create");
+ action = Assert.Single(actions, a => a.ActionName == "Create");
Assert.Equal("Store", action.GetProperty().GroupName);
}
@@ -1331,7 +1331,7 @@ public void GetDescriptors_SplitsConstraintsBasedOnControllerRoute()
var provider = GetProvider(typeof(MultipleRouteProviderOnActionAndControllerController).GetTypeInfo());
// Act
- var actions = provider.GetDescriptors().Where(a => a.Name == actionName);
+ var actions = provider.GetDescriptors().Where(a => a.ActionName == actionName);
// Assert
Assert.Equal(2, actions.Count());
@@ -1358,7 +1358,7 @@ public void GetDescriptors_SplitsConstraintsBasedOnControllerRoute_MultipleRoute
var provider = GetProvider(typeof(MultipleRouteProviderOnActionAndControllerController).GetTypeInfo());
// Act
- var actions = provider.GetDescriptors().Where(a => a.Name == actionName);
+ var actions = provider.GetDescriptors().Where(a => a.ActionName == actionName);
// Assert
Assert.Equal(4, actions.Count());
@@ -1397,7 +1397,7 @@ public void GetDescriptors_SplitsConstraintsBasedOnControllerRoute_Override()
var provider = GetProvider(typeof(MultipleRouteProviderOnActionAndControllerController).GetTypeInfo());
// Act
- var actions = provider.GetDescriptors().Where(a => a.Name == actionName);
+ var actions = provider.GetDescriptors().Where(a => a.ActionName == actionName);
// Assert
Assert.Equal(1, actions.Count());
diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/KnownRouteValueConstraintTests.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/KnownRouteValueConstraintTests.cs
index 84d5da610c..4e7aed2089 100644
--- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/KnownRouteValueConstraintTests.cs
+++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/KnownRouteValueConstraintTests.cs
@@ -5,6 +5,7 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
+using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Routing;
@@ -184,9 +185,9 @@ private static HttpContext GetHttpContext(ActionDescriptor actionDescriptor)
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);
diff --git a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/Internal/PartialViewResultExecutorTest.cs b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/Internal/PartialViewResultExecutorTest.cs
index 7668613052..d6e793f7f7 100644
--- a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/Internal/PartialViewResultExecutorTest.cs
+++ b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/Internal/PartialViewResultExecutorTest.cs
@@ -6,6 +6,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
+using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ViewEngines;
@@ -57,11 +58,9 @@ public void FindView_UsesViewEngine_FromPartialViewResult()
public void FindView_UsesActionDescriptorName_IfViewNameIsNull()
{
// Arrange
- var context = GetActionContext();
- var executor = GetViewExecutor();
-
var viewName = "some-view-name";
- context.ActionDescriptor.Name = viewName;
+ var context = GetActionContext(viewName);
+ var executor = GetViewExecutor();
var viewResult = new PartialViewResult
{
@@ -309,9 +308,9 @@ public async Task ExecuteAsync_UsesStatusCode_FromPartialViewResult()
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());
+ return new ActionContext(new DefaultHttpContext(), new RouteData(), new ControllerActionDescriptor() { ActionName = actionName });
}
private PartialViewResultExecutor GetViewExecutor(DiagnosticSource diagnosticSource = null)
diff --git a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/Internal/ViewResultExecutorTest.cs b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/Internal/ViewResultExecutorTest.cs
index 4134549e66..64b889f1cc 100644
--- a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/Internal/ViewResultExecutorTest.cs
+++ b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/Internal/ViewResultExecutorTest.cs
@@ -6,6 +6,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
+using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Routing;
@@ -56,11 +57,9 @@ public void FindView_UsesViewEngine_FromViewResult()
public void FindView_UsesActionDescriptorName_IfViewNameIsNull()
{
// Arrange
- var context = GetActionContext();
- var executor = GetViewExecutor();
-
var viewName = "some-view-name";
- context.ActionDescriptor.Name = viewName;
+ var context = GetActionContext(viewName);
+ var executor = GetViewExecutor();
var viewResult = new ViewResult
{
@@ -299,9 +298,9 @@ public async Task ExecuteAsync_UsesStatusCode_FromViewResult()
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());
+ return new ActionContext(new DefaultHttpContext(), new RouteData(), new ControllerActionDescriptor() { ActionName = actionName });
}
private ViewResultExecutor GetViewExecutor(DiagnosticListener diagnosticSource = null)
diff --git a/test/Microsoft.AspNetCore.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs b/test/Microsoft.AspNetCore.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs
index f8987b4315..c3f2b4a866 100644
--- a/test/Microsoft.AspNetCore.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs
+++ b/test/Microsoft.AspNetCore.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs
@@ -272,7 +272,7 @@ public void GetActions_Parameters_SimpleTypeFromUriByDefault()
var controllerType = typeof(TestControllers.EmployeesController).GetTypeInfo();
var actions = results
.Where(ad => ad.ControllerTypeInfo == controllerType)
- .Where(ad => ad.Name == "Get")
+ .Where(ad => ad.ActionName == "Get")
.ToArray();
Assert.NotEmpty(actions);
@@ -301,7 +301,7 @@ public void GetActions_Parameters_ComplexTypeFromBodyByDefault()
var controllerType = typeof(TestControllers.EmployeesController).GetTypeInfo();
var actions = results
.Where(ad => ad.ControllerTypeInfo == controllerType)
- .Where(ad => ad.Name == "Put")
+ .Where(ad => ad.ActionName == "Put")
.ToArray();
Assert.NotEmpty(actions);
@@ -328,7 +328,7 @@ public void GetActions_Parameters_WithBindingSource()
var controllerType = typeof(TestControllers.EmployeesController).GetTypeInfo();
var actions = results
.Where(ad => ad.ControllerTypeInfo == controllerType)
- .Where(ad => ad.Name == "Post")
+ .Where(ad => ad.ActionName == "Post")
.ToArray();
Assert.NotEmpty(actions);
@@ -357,7 +357,7 @@ public void GetActions_Parameters_ImplicitOptional(string name)
var controllerType = typeof(TestControllers.EventsController).GetTypeInfo();
var actions = results
.Where(ad => ad.ControllerTypeInfo == controllerType)
- .Where(ad => ad.Name == name)
+ .Where(ad => ad.ActionName == name)
.ToArray();
Assert.NotEmpty(actions);
diff --git a/test/WebSites/ApplicationModelWebSite/Controllers/ActionModelController.cs b/test/WebSites/ApplicationModelWebSite/Controllers/ActionModelController.cs
index 7384251025..d68ad4db03 100644
--- a/test/WebSites/ApplicationModelWebSite/Controllers/ActionModelController.cs
+++ b/test/WebSites/ApplicationModelWebSite/Controllers/ActionModelController.cs
@@ -14,7 +14,7 @@ public class ActionModelController : Controller
[ActionName2("ActionName")]
public string GetActionName()
{
- return ControllerContext.ActionDescriptor.Name;
+ return ControllerContext.ActionDescriptor.ActionName;
}
private class ActionName2Attribute : Attribute, IActionModelConvention
diff --git a/test/WebSites/BasicWebSite/Controllers/RoutingController.cs b/test/WebSites/BasicWebSite/Controllers/RoutingController.cs
index 34be10972f..c5576b4685 100644
--- a/test/WebSites/BasicWebSite/Controllers/RoutingController.cs
+++ b/test/WebSites/BasicWebSite/Controllers/RoutingController.cs
@@ -3,6 +3,7 @@
using System.Linq;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
namespace BasicWebSite
@@ -29,7 +30,7 @@ public override void OnActionExecuting(ActionExecutingContext context)
{
if (!context.RouteData.DataTokens.ContainsKey("actionName"))
{
- context.RouteData.DataTokens.Add("actionName", context.ActionDescriptor.Name);
+ context.RouteData.DataTokens.Add("actionName", ((ControllerActionDescriptor)context.ActionDescriptor).ActionName);
}
}
diff --git a/test/WebSites/FormatterWebSite/ValidateBodyParameterAttribute.cs b/test/WebSites/FormatterWebSite/ValidateBodyParameterAttribute.cs
index 8848f815bb..0be7c1fc33 100644
--- a/test/WebSites/FormatterWebSite/ValidateBodyParameterAttribute.cs
+++ b/test/WebSites/FormatterWebSite/ValidateBodyParameterAttribute.cs
@@ -3,6 +3,7 @@
using System.Linq;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.ModelBinding;
@@ -27,7 +28,7 @@ public override void OnActionExecuting(ActionExecutingContext context)
{
var errorInfo = new ErrorInfo
{
- ActionName = context.ActionDescriptor.Name,
+ ActionName = ((ControllerActionDescriptor)context.ActionDescriptor).ActionName,
ParameterName = bodyParameter.Name,
Errors = parameterBindingErrors.Select(x => x.ErrorMessage).ToList(),
Source = "filter"
diff --git a/test/WebSites/RoutingWebSite/TestResponseGenerator.cs b/test/WebSites/RoutingWebSite/TestResponseGenerator.cs
index d5bad4c7a7..9b85f04456 100644
--- a/test/WebSites/RoutingWebSite/TestResponseGenerator.cs
+++ b/test/WebSites/RoutingWebSite/TestResponseGenerator.cs
@@ -51,7 +51,7 @@ public JsonResult Generate(params string[] expectedUrls)
routeName = attributeRoutingInfo == null ? null : attributeRoutingInfo.Name,
routeValues = new Dictionary(_actionContext.RouteData.Values),
- action = _actionContext.ActionDescriptor.Name,
+ action = ((ControllerActionDescriptor) _actionContext.ActionDescriptor).ActionName,
controller = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ControllerName,
link,
diff --git a/test/WebSites/VersioningWebSite/TestResponseGenerator.cs b/test/WebSites/VersioningWebSite/TestResponseGenerator.cs
index 6b74671f5a..d9ff985c34 100644
--- a/test/WebSites/VersioningWebSite/TestResponseGenerator.cs
+++ b/test/WebSites/VersioningWebSite/TestResponseGenerator.cs
@@ -49,7 +49,7 @@ public JsonResult Generate(params string[] expectedUrls)
routeName = attributeRoutingInfo == null ? null : attributeRoutingInfo.Name,
routeValues = new Dictionary(_actionContext.RouteData.Values),
- action = _actionContext.ActionDescriptor.Name,
+ action = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ActionName,
controller = ((ControllerActionDescriptor)_actionContext.ActionDescriptor).ControllerName,
link,
diff --git a/test/WebSites/WebApiCompatShimWebSite/ActionSelectionFilter.cs b/test/WebSites/WebApiCompatShimWebSite/ActionSelectionFilter.cs
index fb1143fd39..083d9cb643 100644
--- a/test/WebSites/WebApiCompatShimWebSite/ActionSelectionFilter.cs
+++ b/test/WebSites/WebApiCompatShimWebSite/ActionSelectionFilter.cs
@@ -20,7 +20,7 @@ public override void OnActionExecuted(ActionExecutedContext context)
{
JsonConvert.SerializeObject(new
{
- ActionName = action.Name,
+ ActionName = action.ActionName,
ControllerName = action.ControllerName
})
});