From d3ef91ea91ecbc56126895723bed9b463c9d6bfa Mon Sep 17 00:00:00 2001 From: Murat Girgin Date: Tue, 7 Oct 2014 23:29:23 -0700 Subject: [PATCH] Fixing NRE with logging --- .../Logging/DefaultActionSelectorSelectAsyncValues.cs | 2 +- .../DefaultActionSelectorTests.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.Core/Logging/DefaultActionSelectorSelectAsyncValues.cs b/src/Microsoft.AspNet.Mvc.Core/Logging/DefaultActionSelectorSelectAsyncValues.cs index 084e4ac875..e5f85b3202 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Logging/DefaultActionSelectorSelectAsyncValues.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Logging/DefaultActionSelectorSelectAsyncValues.cs @@ -75,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.Logging private string Formatter(ActionDescriptor descriptor) { - return descriptor?.DisplayName ?? "No action selected"; + return descriptor != null ? descriptor.DisplayName : "No action selected"; } } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionSelectorTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionSelectorTests.cs index ba9c98d066..5c125d8403 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionSelectorTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionSelectorTests.cs @@ -57,7 +57,8 @@ namespace Microsoft.AspNet.Mvc Assert.Empty(values.ActionsMatchingRouteConstraints); Assert.Empty(values.ActionsMatchingActionConstraints); Assert.Empty(values.FinalMatches); - Assert.Null(values.SelectedAction); + Assert.Null(values.SelectedAction); + Assert.DoesNotThrow(() => values.Summary); } [Fact] @@ -160,6 +161,7 @@ namespace Microsoft.AspNet.Mvc Assert.Equal(actions, values.ActionsMatchingActionConstraints); Assert.Equal(actions, values.FinalMatches); Assert.Null(values.SelectedAction); + Assert.DoesNotThrow(() => values.Summary); } [Fact]