From f5b3ae4a3bf31171f93dab4115b07cade039f7ea Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Thu, 1 May 2014 23:14:47 -0700 Subject: [PATCH] Renaming Exception Filter methods These were accidentally the same names as the action filter methods. Oopsies. Name taken from MVC and appended Async for the async version because that's how we roll. --- .../Filters/ExceptionFilterAttribute.cs | 6 ++-- .../Filters/IAsyncExceptionFilter.cs | 2 +- .../Filters/IExceptionFilter.cs | 2 +- .../ReflectedActionInvoker.cs | 4 +-- .../ReflectedActionInvokerTest.cs | 36 +++++++++---------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/ExceptionFilterAttribute.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/ExceptionFilterAttribute.cs index c4e3f3e927..b4d6fb9880 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Filters/ExceptionFilterAttribute.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Filters/ExceptionFilterAttribute.cs @@ -26,13 +26,13 @@ namespace Microsoft.AspNet.Mvc public int Order { get; set; } #pragma warning disable 1998 - public async Task OnActionExecutedAsync([NotNull] ExceptionContext context) + public async Task OnExceptionAsync([NotNull] ExceptionContext context) { - OnActionExecuted(context); + OnException(context); } #pragma warning restore 1998 - public void OnActionExecuted([NotNull] ExceptionContext context) + public void OnException([NotNull] ExceptionContext context) { } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/IAsyncExceptionFilter.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/IAsyncExceptionFilter.cs index 176d956551..0b65b3ab86 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Filters/IAsyncExceptionFilter.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Filters/IAsyncExceptionFilter.cs @@ -22,6 +22,6 @@ namespace Microsoft.AspNet.Mvc { public interface IAsyncExceptionFilter : IFilter { - Task OnActionExecutedAsync([NotNull] ExceptionContext context); + Task OnExceptionAsync([NotNull] ExceptionContext context); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/IExceptionFilter.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/IExceptionFilter.cs index 1ed3abac6a..a3004e66bb 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Filters/IExceptionFilter.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Filters/IExceptionFilter.cs @@ -22,6 +22,6 @@ namespace Microsoft.AspNet.Mvc { public interface IExceptionFilter : IFilter { - void OnActionExecuted([NotNull] ExceptionContext context); + void OnException([NotNull] ExceptionContext context); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvoker.cs b/src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvoker.cs index e9e760b05a..dbc8937fc9 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvoker.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvoker.cs @@ -145,7 +145,7 @@ namespace Microsoft.AspNet.Mvc { // Exception filters only run when there's an exception - unsetting it will short-circuit // other exception filters. - await current.FilterAsync.OnActionExecutedAsync(_exceptionContext); + await current.FilterAsync.OnExceptionAsync(_exceptionContext); } } else if (current.Filter != null) @@ -159,7 +159,7 @@ namespace Microsoft.AspNet.Mvc { // Exception filters only run when there's an exception - unsetting it will short-circuit // other exception filters. - current.Filter.OnActionExecuted(_exceptionContext); + current.Filter.OnException(_exceptionContext); } } else diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ReflectedActionInvokerTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ReflectedActionInvokerTest.cs index daaa31ddd5..6ef4c03ee6 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ReflectedActionInvokerTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ReflectedActionInvokerTest.cs @@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Mvc // Arrange var filter = new Mock(MockBehavior.Strict); filter - .Setup(f => f.OnActionExecuted(It.IsAny())) + .Setup(f => f.OnException(It.IsAny())) .Verifiable(); var invoker = CreateInvoker(filter.Object, actionThrows: false); @@ -51,7 +51,7 @@ namespace Microsoft.AspNet.Mvc await invoker.InvokeActionAsync(); // Assert - filter.Verify(f => f.OnActionExecuted(It.IsAny()), Times.Never()); + filter.Verify(f => f.OnException(It.IsAny()), Times.Never()); } [Fact] @@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Mvc // Arrange var filter = new Mock(MockBehavior.Strict); filter - .Setup(f => f.OnActionExecutedAsync(It.IsAny())) + .Setup(f => f.OnExceptionAsync(It.IsAny())) .Returns((context) => Task.FromResult(null)) .Verifiable(); @@ -71,7 +71,7 @@ namespace Microsoft.AspNet.Mvc // Assert filter.Verify( - f => f.OnActionExecutedAsync(It.IsAny()), + f => f.OnExceptionAsync(It.IsAny()), Times.Never()); } @@ -84,7 +84,7 @@ namespace Microsoft.AspNet.Mvc var filter = new Mock(MockBehavior.Strict); filter - .Setup(f => f.OnActionExecuted(It.IsAny())) + .Setup(f => f.OnException(It.IsAny())) .Callback(context => { exception = context.Exception; @@ -101,7 +101,7 @@ namespace Microsoft.AspNet.Mvc await invoker.InvokeActionAsync(); // Assert - filter.Verify(f => f.OnActionExecuted(It.IsAny()), Times.Once()); + filter.Verify(f => f.OnException(It.IsAny()), Times.Once()); Assert.Same(_actionException, exception); Assert.Null(result); @@ -116,7 +116,7 @@ namespace Microsoft.AspNet.Mvc var filter = new Mock(MockBehavior.Strict); filter - .Setup(f => f.OnActionExecutedAsync(It.IsAny())) + .Setup(f => f.OnExceptionAsync(It.IsAny())) .Callback(context => { exception = context.Exception; @@ -135,7 +135,7 @@ namespace Microsoft.AspNet.Mvc // Assert filter.Verify( - f => f.OnActionExecutedAsync(It.IsAny()), + f => f.OnExceptionAsync(It.IsAny()), Times.Once()); Assert.Same(_actionException, exception); @@ -150,7 +150,7 @@ namespace Microsoft.AspNet.Mvc var filter2 = new Mock(MockBehavior.Strict); filter2 - .Setup(f => f.OnActionExecuted(It.IsAny())) + .Setup(f => f.OnException(It.IsAny())) .Callback(context => { context.Exception = null; @@ -164,7 +164,7 @@ namespace Microsoft.AspNet.Mvc // Assert filter2.Verify( - f => f.OnActionExecuted(It.IsAny()), + f => f.OnException(It.IsAny()), Times.Once()); } @@ -176,7 +176,7 @@ namespace Microsoft.AspNet.Mvc var filter2 = new Mock(MockBehavior.Strict); filter2 - .Setup(f => f.OnActionExecutedAsync(It.IsAny())) + .Setup(f => f.OnExceptionAsync(It.IsAny())) .Callback(context => { context.Exception = null; @@ -191,7 +191,7 @@ namespace Microsoft.AspNet.Mvc // Assert filter2.Verify( - f => f.OnActionExecutedAsync(It.IsAny()), + f => f.OnExceptionAsync(It.IsAny()), Times.Once()); } @@ -201,7 +201,7 @@ namespace Microsoft.AspNet.Mvc // Arrange var filter = new Mock(MockBehavior.Strict); filter - .Setup(f => f.OnActionExecuted(It.IsAny())) + .Setup(f => f.OnException(It.IsAny())) .Verifiable(); var invoker = CreateInvoker(filter.Object, actionThrows: true); @@ -210,7 +210,7 @@ namespace Microsoft.AspNet.Mvc await Assert.ThrowsAsync(_actionException.GetType(), async () => await invoker.InvokeActionAsync()); // Assert - filter.Verify(f => f.OnActionExecuted(It.IsAny()), Times.Once()); + filter.Verify(f => f.OnException(It.IsAny()), Times.Once()); } [Fact] @@ -225,7 +225,7 @@ namespace Microsoft.AspNet.Mvc var filter = new Mock(MockBehavior.Strict); filter - .Setup(f => f.OnActionExecuted(It.IsAny())) + .Setup(f => f.OnException(It.IsAny())) .Callback(c => c.Result = result.Object) .Verifiable(); @@ -237,7 +237,7 @@ namespace Microsoft.AspNet.Mvc await invoker.InvokeActionAsync(); // Assert - filter.Verify(f => f.OnActionExecuted(It.IsAny()), Times.Once()); + filter.Verify(f => f.OnException(It.IsAny()), Times.Once()); result.Verify(r => r.ExecuteResultAsync(It.IsAny()), Times.Once()); } @@ -339,7 +339,7 @@ namespace Microsoft.AspNet.Mvc var exceptionFilter = new Mock(MockBehavior.Strict); exceptionFilter - .Setup(f => f.OnActionExecuted(It.IsAny())) + .Setup(f => f.OnException(It.IsAny())) .Callback(context => { exception = context.Exception; @@ -373,7 +373,7 @@ namespace Microsoft.AspNet.Mvc await invoker.InvokeActionAsync(); // Assert - exceptionFilter.Verify(f => f.OnActionExecuted(It.IsAny()), Times.Once()); + exceptionFilter.Verify(f => f.OnException(It.IsAny()), Times.Once()); authorizationFilter1.Verify(f => f.OnAuthorization(It.IsAny()), Times.Once()); }