Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Commit aa959aa

Browse files
committed
Updated action id to be just guid and addressed other feedback.
1 parent d00db54 commit aa959aa

File tree

4 files changed

+9
-43
lines changed

4 files changed

+9
-43
lines changed

src/Microsoft.AspNet.Mvc.Core/ActionDescriptor.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,17 @@ namespace Microsoft.AspNet.Mvc
99
{
1010
public class ActionDescriptor
1111
{
12-
private readonly string _guid;
13-
1412
public ActionDescriptor()
1513
{
1614
Properties = new Dictionary<object, object>();
1715
RouteValueDefaults = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
18-
_guid = Guid.NewGuid().ToString();
16+
Id = Guid.NewGuid().ToString();
1917
}
2018

2119
/// <summary>
2220
/// Gets an id which uniquely identifies the action.
23-
/// It is of the format "<see cref="DisplayName"/>_<see cref="Guid"/>".
2421
/// </summary>
25-
public string Id
26-
{
27-
get
28-
{
29-
return string.Format("{0}_{1}", DisplayName, _guid);
30-
}
31-
}
22+
public string Id { get; }
3223

3324
public virtual string Name { get; set; }
3425

src/Microsoft.AspNet.Mvc.Core/DefaultActionSelector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public Task<ActionDescriptor> SelectAsync([NotNull] RouteContext context)
7676
Environment.NewLine,
7777
finalMatches.Select(a => a.DisplayName));
7878

79-
_logger.LogError(
80-
$"Request matched multiple actions resulting in ambiguity. Matching actions: {actionNames}");
79+
_logger.LogError("Request matched multiple actions resulting in ambiguity. " +
80+
"Matching actions: {AmbiguousActions}", actionNames);
8181

8282
var message = Resources.FormatDefaultActionSelector_AmbiguousActions(
8383
Environment.NewLine,

test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionSelectorTests.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,6 @@ namespace Microsoft.AspNet.Mvc
2525
{
2626
public class DefaultActionSelectorTests
2727
{
28-
// When no actions match, MvcRouteHandler logs the message.
29-
[Fact]
30-
public async void SelectAsync_NoMatchedActions_NothingIsLogged()
31-
{
32-
// Arrange
33-
var sink = new TestSink();
34-
var loggerFactory = new TestLoggerFactory(sink);
35-
36-
var routeContext = CreateRouteContext("POST");
37-
38-
var actions = new ActionDescriptor[0];
39-
var selector = CreateSelector(actions, loggerFactory);
40-
41-
// Act
42-
var action = await selector.SelectAsync(routeContext);
43-
44-
// Assert
45-
Assert.Empty(sink.Scopes);
46-
}
47-
4828
[Fact]
4929
public async void SelectAsync_AmbiguousActions_LogIsCorrect()
5030
{

test/Microsoft.AspNet.Mvc.Core.Test/MvcRouteHandlerTests.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,17 @@ public async Task RouteAsync_Success_LogsCorrectValues()
2323
// Arrange
2424
var sink = new TestSink();
2525
var loggerFactory = new TestLoggerFactory(sink);
26-
var displayName = "A.B.C";
27-
var actionDescriptor = new Mock<ActionDescriptor>();
28-
actionDescriptor.SetupGet(ad => ad.DisplayName)
29-
.Returns(displayName);
30-
var context = CreateRouteContext(actionDescriptor: actionDescriptor.Object, loggerFactory: loggerFactory);
26+
var context = CreateRouteContext(loggerFactory: loggerFactory);
3127
var handler = new MvcRouteHandler();
32-
var expectedMessage = $"Executing action {displayName}";
33-
28+
3429
// Act
3530
await handler.RouteAsync(context);
3631

3732
// Assert
3833
Assert.Single(sink.Scopes);
39-
Assert.StartsWith($"ActionId: {displayName}_", sink.Scopes[0].Scope?.ToString());
34+
Assert.StartsWith("ActionId: ", sink.Scopes[0].Scope?.ToString());
4035
Assert.Single(sink.Writes);
41-
Assert.Equal(expectedMessage, sink.Writes[0].State?.ToString());
36+
Assert.StartsWith("Executing action ", sink.Writes[0].State?.ToString());
4237
}
4338

4439
[Fact]
@@ -198,7 +193,7 @@ private RouteContext CreateRouteContext(
198193
{
199194
var mockContextAccessor = new Mock<IScopedInstance<ActionContext>>();
200195

201-
if(actionDescriptor == null)
196+
if (actionDescriptor == null)
202197
{
203198
var mockAction = new Mock<ActionDescriptor>();
204199
actionDescriptor = mockAction.Object;

0 commit comments

Comments
 (0)