diff --git a/src/Microsoft.AspNet.Mvc.Core/AuthorizationFilterAttribute.cs b/src/Microsoft.AspNet.Mvc.Core/AuthorizationFilterAttribute.cs index 7eb7168423..a6d66e138b 100644 --- a/src/Microsoft.AspNet.Mvc.Core/AuthorizationFilterAttribute.cs +++ b/src/Microsoft.AspNet.Mvc.Core/AuthorizationFilterAttribute.cs @@ -14,12 +14,11 @@ namespace Microsoft.AspNet.Mvc { public int Order { get; set; } -#pragma warning disable 1998 - public virtual async Task OnAuthorizationAsync([NotNull] AuthorizationContext context) + public virtual Task OnAuthorizationAsync([NotNull] AuthorizationContext context) { OnAuthorization(context); + return TaskCache.CompletedTask; } -#pragma warning restore 1998 public virtual void OnAuthorization([NotNull] AuthorizationContext context) { diff --git a/src/Microsoft.AspNet.Mvc.Core/ContentResult.cs b/src/Microsoft.AspNet.Mvc.Core/ContentResult.cs index f57d38fab1..b9b3acd84d 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ContentResult.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ContentResult.cs @@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Mvc /// public int? StatusCode { get; set; } - public override async Task ExecuteResultAsync([NotNull] ActionContext context) + public override Task ExecuteResultAsync([NotNull] ActionContext context) { var response = context.HttpContext.Response; var contentTypeHeader = ContentType; @@ -54,8 +54,9 @@ namespace Microsoft.AspNet.Mvc if (Content != null) { - await response.WriteAsync(Content, contentTypeHeader?.Encoding ?? DefaultContentType.Encoding); + return response.WriteAsync(Content, contentTypeHeader?.Encoding ?? DefaultContentType.Encoding); } + return TaskCache.CompletedTask; } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/ControllerActionExecutor.cs b/src/Microsoft.AspNet.Mvc.Core/ControllerActionExecutor.cs index 9e306ef071..f37fc5b1c5 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ControllerActionExecutor.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ControllerActionExecutor.cs @@ -25,16 +25,16 @@ namespace Microsoft.AspNet.Mvc return CastToObject(task); } - public static async Task ExecuteAsync( + public static Task ExecuteAsync( MethodInfo actionMethodInfo, object instance, IDictionary actionArguments) { var orderedArguments = PrepareArguments(actionArguments, actionMethodInfo.GetParameters()); - return await ExecuteAsync(actionMethodInfo, instance, orderedArguments); + return ExecuteAsync(actionMethodInfo, instance, orderedArguments); } - public static async Task ExecuteAsync( + public static Task ExecuteAsync( MethodInfo actionMethodInfo, object instance, object[] orderedActionArguments) @@ -51,7 +51,7 @@ namespace Microsoft.AspNet.Mvc exceptionDispatchInfo.Throw(); } - return await CoerceResultToTaskAsync( + return CoerceResultToTaskAsync( invocationResult, actionMethodInfo.ReturnType, actionMethodInfo.Name, diff --git a/src/Microsoft.AspNet.Mvc.Core/ExceptionFilterAttribute.cs b/src/Microsoft.AspNet.Mvc.Core/ExceptionFilterAttribute.cs index 652c95708d..a0a46fedb2 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ExceptionFilterAttribute.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ExceptionFilterAttribute.cs @@ -12,12 +12,11 @@ namespace Microsoft.AspNet.Mvc { public int Order { get; set; } -#pragma warning disable 1998 - public virtual async Task OnExceptionAsync([NotNull] ExceptionContext context) + public virtual Task OnExceptionAsync([NotNull] ExceptionContext context) { OnException(context); + return TaskCache.CompletedTask; } -#pragma warning restore 1998 public virtual void OnException([NotNull] ExceptionContext context) { diff --git a/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs b/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs index ccf33a0487..2550951b65 100644 --- a/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs +++ b/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs @@ -186,12 +186,12 @@ namespace Microsoft.AspNet.Mvc.Core return context.Results.Select(item => item.Filter).Where(filter => filter != null).ToArray(); } - private async Task InvokeAllAuthorizationFiltersAsync() + private Task InvokeAllAuthorizationFiltersAsync() { _cursor.SetStage(FilterStage.AuthorizationFilters); _authorizationContext = new AuthorizationContext(ActionContext, _filters); - await InvokeAuthorizationFilterAsync(); + return InvokeAuthorizationFilterAsync(); } private async Task InvokeAuthorizationFilterAsync() @@ -236,7 +236,7 @@ namespace Microsoft.AspNet.Mvc.Core } } - private async Task InvokeAllResourceFiltersAsync() + private Task InvokeAllResourceFiltersAsync() { _cursor.SetStage(FilterStage.ResourceFilters); @@ -249,7 +249,7 @@ namespace Microsoft.AspNet.Mvc.Core context.ValueProviderFactories = new CopyOnWriteList(_valueProviderFactories); _resourceExecutingContext = context; - await InvokeResourceFilterAsync(); + return InvokeResourceFilterAsync(); } private async Task InvokeResourceFilterAsync() @@ -397,11 +397,11 @@ namespace Microsoft.AspNet.Mvc.Core return _resourceExecutedContext; } - private async Task InvokeAllExceptionFiltersAsync() + private Task InvokeAllExceptionFiltersAsync() { _cursor.SetStage(FilterStage.ExceptionFilters); - await InvokeExceptionFilterAsync(); + return InvokeExceptionFilterAsync(); } private async Task InvokeExceptionFilterAsync() @@ -654,24 +654,9 @@ namespace Microsoft.AspNet.Mvc.Core { await item.FilterAsync.OnResultExecutionAsync(_resultExecutingContext, InvokeResultFilterAsync); - if (_resultExecutedContext == null) + if (_resultExecutedContext == null || _resultExecutingContext.Cancel == true) { - // Short-circuited by not calling next - - _logger.LogVerbose(ResourceFilterShortCircuitLogMessage, item.FilterAsync.GetType().FullName); - - _resultExecutedContext = new ResultExecutedContext( - _resultExecutingContext, - _filters, - _resultExecutingContext.Result, - Instance) - { - Canceled = true, - }; - } - else if (_resultExecutingContext.Cancel == true) - { - // Short-circuited by setting Cancel == true + // Short-circuited by not calling next || Short-circuited by setting Cancel == true _logger.LogVerbose(ResourceFilterShortCircuitLogMessage, item.FilterAsync.GetType().FullName); diff --git a/src/Microsoft.AspNet.Mvc.Core/HttpResponseStreamWriter.cs b/src/Microsoft.AspNet.Mvc.Core/HttpResponseStreamWriter.cs index e4d848c21e..25b197d48d 100644 --- a/src/Microsoft.AspNet.Mvc.Core/HttpResponseStreamWriter.cs +++ b/src/Microsoft.AspNet.Mvc.Core/HttpResponseStreamWriter.cs @@ -146,9 +146,9 @@ namespace Microsoft.AspNet.Mvc FlushInternal(true, true); } - public override async Task FlushAsync() + public override Task FlushAsync() { - await FlushInternalAsync(true, true); + return FlushInternalAsync(flushStream: true, flushEncoder: true); } // Do not flush the stream on Dispose, as this will cause response to be diff --git a/src/Microsoft.AspNet.Mvc.Core/InputFormatter.cs b/src/Microsoft.AspNet.Mvc.Core/InputFormatter.cs index 4e09ebcef9..cdf8d971ce 100644 --- a/src/Microsoft.AspNet.Mvc.Core/InputFormatter.cs +++ b/src/Microsoft.AspNet.Mvc.Core/InputFormatter.cs @@ -82,15 +82,15 @@ namespace Microsoft.AspNet.Mvc } /// - public virtual async Task ReadAsync(InputFormatterContext context) + public virtual Task ReadAsync(InputFormatterContext context) { var request = context.HttpContext.Request; if (request.ContentLength == 0) { - return GetDefaultValueForType(context.ModelType); + return Task.FromResult(GetDefaultValueForType(context.ModelType)); } - return await ReadRequestBodyAsync(context); + return ReadRequestBodyAsync(context); } /// diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/CollectionModelBinder.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/CollectionModelBinder.cs index 6df8fc7510..60f6a6131e 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/CollectionModelBinder.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/CollectionModelBinder.cs @@ -189,13 +189,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding } // Used when the ValueProvider contains the collection to be bound as multiple elements, e.g. foo[0], foo[1]. - private async Task BindComplexCollection(ModelBindingContext bindingContext) + private Task BindComplexCollection(ModelBindingContext bindingContext) { var indexPropertyName = ModelNames.CreatePropertyModelName(bindingContext.ModelName, "index"); var valueProviderResultIndex = bindingContext.ValueProvider.GetValue(indexPropertyName); var indexNames = GetIndexNamesFromValueProviderResult(valueProviderResultIndex); - return await BindComplexCollectionFromIndexes(bindingContext, indexNames); + return BindComplexCollectionFromIndexes(bindingContext, indexNames); } // Internal for testing. diff --git a/src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs b/src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs index 82ece340b5..4246fb3e90 100644 --- a/src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs +++ b/src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs @@ -101,7 +101,7 @@ namespace Microsoft.AspNet.Mvc } } - private async Task InvokeActionAsync(RouteContext context, ActionDescriptor actionDescriptor) + private Task InvokeActionAsync(RouteContext context, ActionDescriptor actionDescriptor) { var actionContext = new ActionContext(context.HttpContext, context.RouteData, actionDescriptor); _actionContextAccessor.ActionContext = actionContext; @@ -114,7 +114,7 @@ namespace Microsoft.AspNet.Mvc actionDescriptor.DisplayName)); } - await invoker.InvokeAsync(); + return invoker.InvokeAsync(); } private void EnsureServices(HttpContext context) diff --git a/src/Microsoft.AspNet.Mvc.Core/ObjectResult.cs b/src/Microsoft.AspNet.Mvc.Core/ObjectResult.cs index 84aae59641..ef4908a229 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ObjectResult.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ObjectResult.cs @@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Mvc /// public int? StatusCode { get; set; } - public override async Task ExecuteResultAsync(ActionContext context) + public override Task ExecuteResultAsync(ActionContext context) { var logger = context.HttpContext.RequestServices.GetRequiredService>(); @@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Mvc logger.LogWarning("No output formatter was found to write the response."); context.HttpContext.Response.StatusCode = StatusCodes.Status406NotAcceptable; - return; + return TaskCache.CompletedTask; } logger.LogVerbose( @@ -75,7 +75,7 @@ namespace Microsoft.AspNet.Mvc } OnFormatting(context); - await selectedFormatter.WriteAsync(formatterContext); + return selectedFormatter.WriteAsync(formatterContext); } public virtual IOutputFormatter SelectFormatter( diff --git a/src/Microsoft.AspNet.Mvc.Core/OutputFormatter.cs b/src/Microsoft.AspNet.Mvc.Core/OutputFormatter.cs index dc41744ed6..339e88d808 100644 --- a/src/Microsoft.AspNet.Mvc.Core/OutputFormatter.cs +++ b/src/Microsoft.AspNet.Mvc.Core/OutputFormatter.cs @@ -158,10 +158,10 @@ namespace Microsoft.AspNet.Mvc } /// - public async Task WriteAsync([NotNull] OutputFormatterContext context) + public Task WriteAsync([NotNull] OutputFormatterContext context) { WriteResponseHeaders(context); - await WriteResponseBodyAsync(context); + return WriteResponseBodyAsync(context); } /// diff --git a/src/Microsoft.AspNet.Mvc.Core/StringOutputFormatter.cs b/src/Microsoft.AspNet.Mvc.Core/StringOutputFormatter.cs index 2628020d94..64fe5db833 100644 --- a/src/Microsoft.AspNet.Mvc.Core/StringOutputFormatter.cs +++ b/src/Microsoft.AspNet.Mvc.Core/StringOutputFormatter.cs @@ -37,17 +37,17 @@ namespace Microsoft.AspNet.Mvc return false; } - public override async Task WriteResponseBodyAsync(OutputFormatterContext context) + public override Task WriteResponseBodyAsync(OutputFormatterContext context) { var valueAsString = (string)context.Object; if (string.IsNullOrEmpty(valueAsString)) { - return; + return TaskCache.CompletedTask; } var response = context.HttpContext.Response; - await response.WriteAsync(valueAsString, context.SelectedEncoding); + return response.WriteAsync(valueAsString, context.SelectedEncoding); } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/TaskCache.cs b/src/Microsoft.AspNet.Mvc.Core/TaskCache.cs new file mode 100644 index 0000000000..cde5ab7b5a --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Core/TaskCache.cs @@ -0,0 +1,29 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading.Tasks; + +namespace Microsoft.AspNet.Mvc +{ + public static class TaskCache + { +#if DNX451 + static readonly Task _completedTask = Task.FromResult(0); +#endif + + /// Gets a task that's already been completed successfully. + /// May not always return the same instance. + public static Task CompletedTask + { + get + { +#if DNX451 + return _completedTask; +#else + return Task.CompletedTask; +#endif + } + } + } + +} diff --git a/src/Microsoft.AspNet.Mvc.Cors/CorsAuthorizationFilter.cs b/src/Microsoft.AspNet.Mvc.Cors/CorsAuthorizationFilter.cs index 65f3fb9720..c10cb92288 100644 --- a/src/Microsoft.AspNet.Mvc.Cors/CorsAuthorizationFilter.cs +++ b/src/Microsoft.AspNet.Mvc.Cors/CorsAuthorizationFilter.cs @@ -74,7 +74,6 @@ namespace Microsoft.AspNet.Mvc // If this was a preflight, there is no need to run anything else. // Also the response is always 200 so that anyone after mvc can handle the pre flight request. context.Result = new HttpStatusCodeResult(StatusCodes.Status200OK); - await Task.FromResult(true); } // Continue with other filters and action. diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs index bcac22e503..eb7efd26d9 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs @@ -294,9 +294,9 @@ namespace Microsoft.AspNet.Mvc.Razor /// /// A that on completion writes the content. /// - public async Task WriteTagHelperAsync([NotNull] TagHelperExecutionContext tagHelperExecutionContext) + public Task WriteTagHelperAsync([NotNull] TagHelperExecutionContext tagHelperExecutionContext) { - await WriteTagHelperToAsync(Output, tagHelperExecutionContext); + return WriteTagHelperToAsync(Output, tagHelperExecutionContext); } /// @@ -773,10 +773,10 @@ namespace Microsoft.AspNet.Mvc.Razor /// value does not represent the rendered content. /// if is true and the section /// was not registered using the @section in the Razor page. - public async Task RenderSectionAsync([NotNull] string name, bool required) + public Task RenderSectionAsync([NotNull] string name, bool required) { EnsureMethodCanBeInvoked(nameof(RenderSectionAsync)); - return await RenderSectionAsyncCore(name, required); + return RenderSectionAsyncCore(name, required); } private async Task RenderSectionAsyncCore(string sectionName, bool required) diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs index 1353ccdece..332c6aec06 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs @@ -125,7 +125,7 @@ namespace Microsoft.AspNet.Mvc.Razor } } - private async Task RenderPageCoreAsync(IRazorPage page, ViewContext context) + private Task RenderPageCoreAsync(IRazorPage page, ViewContext context) { page.IsPartial = IsPartial; page.ViewContext = context; @@ -135,7 +135,7 @@ namespace Microsoft.AspNet.Mvc.Razor } _pageActivator.Activate(page, context); - await page.ExecuteAsync(); + return page.ExecuteAsync(); } private async Task RenderViewStartAsync(ViewContext context) diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs index ca30aa8cd3..9cdbe4b7e0 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs @@ -1083,7 +1083,8 @@ namespace Microsoft.AspNet.Mvc /// The model instance to update. /// A that on completion returns true if the update is successful. [NonAction] - public virtual Task TryUpdateModelAsync([NotNull] TModel model) + public virtual Task TryUpdateModelAsync( + [NotNull] TModel model) where TModel : class { return TryUpdateModelAsync(model, prefix: string.Empty); @@ -1099,8 +1100,9 @@ namespace Microsoft.AspNet.Mvc /// /// A that on completion returns true if the update is successful. [NonAction] - public virtual async Task TryUpdateModelAsync([NotNull] TModel model, - [NotNull] string prefix) + public virtual Task TryUpdateModelAsync( + [NotNull] TModel model, + [NotNull] string prefix) where TModel : class { if (BindingContext == null) @@ -1111,7 +1113,7 @@ namespace Microsoft.AspNet.Mvc throw new InvalidOperationException(message); } - return await TryUpdateModelAsync(model, prefix, BindingContext.ValueProvider); + return TryUpdateModelAsync(model, prefix, BindingContext.ValueProvider); } /// @@ -1125,9 +1127,10 @@ namespace Microsoft.AspNet.Mvc /// The used for looking up values. /// A that on completion returns true if the update is successful. [NonAction] - public virtual async Task TryUpdateModelAsync([NotNull] TModel model, - [NotNull] string prefix, - [NotNull] IValueProvider valueProvider) + public virtual Task TryUpdateModelAsync( + [NotNull] TModel model, + [NotNull] string prefix, + [NotNull] IValueProvider valueProvider) where TModel : class { if (BindingContext == null) @@ -1138,7 +1141,7 @@ namespace Microsoft.AspNet.Mvc throw new InvalidOperationException(message); } - return await ModelBindingHelper.TryUpdateModelAsync( + return ModelBindingHelper.TryUpdateModelAsync( model, prefix, ActionContext.HttpContext, @@ -1163,7 +1166,7 @@ namespace Microsoft.AspNet.Mvc /// which need to be included for the current model. /// A that on completion returns true if the update is successful. [NonAction] - public async Task TryUpdateModelAsync( + public Task TryUpdateModelAsync( [NotNull] TModel model, string prefix, [NotNull] params Expression>[] includeExpressions) @@ -1177,7 +1180,7 @@ namespace Microsoft.AspNet.Mvc throw new InvalidOperationException(message); } - return await ModelBindingHelper.TryUpdateModelAsync( + return ModelBindingHelper.TryUpdateModelAsync( model, prefix, ActionContext.HttpContext, @@ -1202,7 +1205,7 @@ namespace Microsoft.AspNet.Mvc /// A predicate which can be used to filter properties at runtime. /// A that on completion returns true if the update is successful. [NonAction] - public async Task TryUpdateModelAsync( + public Task TryUpdateModelAsync( [NotNull] TModel model, string prefix, [NotNull] Func predicate) @@ -1216,7 +1219,7 @@ namespace Microsoft.AspNet.Mvc throw new InvalidOperationException(message); } - return await ModelBindingHelper.TryUpdateModelAsync( + return ModelBindingHelper.TryUpdateModelAsync( model, prefix, ActionContext.HttpContext, @@ -1243,7 +1246,7 @@ namespace Microsoft.AspNet.Mvc /// which need to be included for the current model. /// A that on completion returns true if the update is successful. [NonAction] - public async Task TryUpdateModelAsync( + public Task TryUpdateModelAsync( [NotNull] TModel model, string prefix, [NotNull] IValueProvider valueProvider, @@ -1258,7 +1261,7 @@ namespace Microsoft.AspNet.Mvc throw new InvalidOperationException(message); } - return await ModelBindingHelper.TryUpdateModelAsync( + return ModelBindingHelper.TryUpdateModelAsync( model, prefix, ActionContext.HttpContext, @@ -1284,7 +1287,7 @@ namespace Microsoft.AspNet.Mvc /// A predicate which can be used to filter properties at runtime. /// A that on completion returns true if the update is successful. [NonAction] - public async Task TryUpdateModelAsync( + public Task TryUpdateModelAsync( [NotNull] TModel model, string prefix, [NotNull] IValueProvider valueProvider, @@ -1299,7 +1302,7 @@ namespace Microsoft.AspNet.Mvc throw new InvalidOperationException(message); } - return await ModelBindingHelper.TryUpdateModelAsync( + return ModelBindingHelper.TryUpdateModelAsync( model, prefix, ActionContext.HttpContext, @@ -1323,9 +1326,10 @@ namespace Microsoft.AspNet.Mvc /// /// A that on completion returns true if the update is successful. [NonAction] - public virtual async Task TryUpdateModelAsync([NotNull] object model, - [NotNull] Type modelType, - string prefix) + public virtual Task TryUpdateModelAsync( + [NotNull] object model, + [NotNull] Type modelType, + string prefix) { if (BindingContext == null) { @@ -1335,7 +1339,7 @@ namespace Microsoft.AspNet.Mvc throw new InvalidOperationException(message); } - return await ModelBindingHelper.TryUpdateModelAsync( + return ModelBindingHelper.TryUpdateModelAsync( model, modelType, prefix, @@ -1361,7 +1365,7 @@ namespace Microsoft.AspNet.Mvc /// A predicate which can be used to filter properties at runtime. /// A that on completion returns true if the update is successful. [NonAction] - public async Task TryUpdateModelAsync( + public Task TryUpdateModelAsync( [NotNull] object model, [NotNull] Type modelType, string prefix, @@ -1376,7 +1380,7 @@ namespace Microsoft.AspNet.Mvc throw new InvalidOperationException(message); } - return await ModelBindingHelper.TryUpdateModelAsync( + return ModelBindingHelper.TryUpdateModelAsync( model, modelType, prefix, @@ -1397,7 +1401,8 @@ namespace Microsoft.AspNet.Mvc /// The model to validate. /// true if the is valid; false otherwise. [NonAction] - public virtual bool TryValidateModel([NotNull] object model) + public virtual bool TryValidateModel( + [NotNull] object model) { return TryValidateModel(model, prefix: null); } @@ -1410,7 +1415,9 @@ namespace Microsoft.AspNet.Mvc /// /// true if the is valid;false otherwise. [NonAction] - public virtual bool TryValidateModel([NotNull] object model, string prefix) + public virtual bool TryValidateModel( + [NotNull] object model, + string prefix) { if (BindingContext == null) { diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ValidateAntiforgeryTokenAuthorizationFilter.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ValidateAntiforgeryTokenAuthorizationFilter.cs index 7a15d74d9a..54da0e0667 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ValidateAntiforgeryTokenAuthorizationFilter.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ValidateAntiforgeryTokenAuthorizationFilter.cs @@ -16,9 +16,9 @@ namespace Microsoft.AspNet.Mvc _antiforgery = antiforgery; } - public async Task OnAuthorizationAsync([NotNull] AuthorizationContext context) + public Task OnAuthorizationAsync([NotNull] AuthorizationContext context) { - await _antiforgery.ValidateRequestAsync(context.HttpContext); + return _antiforgery.ValidateRequestAsync(context.HttpContext); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/ContentViewComponentResult.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/ContentViewComponentResult.cs index aab3e566e2..e555805318 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/ContentViewComponentResult.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/ContentViewComponentResult.cs @@ -69,9 +69,9 @@ namespace Microsoft.AspNet.Mvc /// /// The . /// A completed . - public async Task ExecuteAsync([NotNull] ViewComponentContext context) + public Task ExecuteAsync([NotNull] ViewComponentContext context) { - await context.Writer.WriteAsync(EncodedContent.ToString()); + return context.Writer.WriteAsync(EncodedContent.ToString()); } } } diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentHelper.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentHelper.cs index 8837d53f88..334b8f9996 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentHelper.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentHelper.cs @@ -88,16 +88,16 @@ namespace Microsoft.AspNet.Mvc.ViewComponents } } - public async Task RenderInvokeAsync([NotNull] string name, params object[] arguments) + public Task RenderInvokeAsync([NotNull] string name, params object[] arguments) { var descriptor = SelectComponent(name); - await InvokeCoreAsync(_viewContext.Writer, descriptor, arguments); + return InvokeCoreAsync(_viewContext.Writer, descriptor, arguments); } - public async Task RenderInvokeAsync([NotNull] Type componentType, params object[] arguments) + public Task RenderInvokeAsync([NotNull] Type componentType, params object[] arguments) { var descriptor = SelectComponent(componentType); - await InvokeCoreAsync(_viewContext.Writer, descriptor, arguments); + return InvokeCoreAsync(_viewContext.Writer, descriptor, arguments); } private ViewComponentDescriptor SelectComponent(string name) @@ -126,7 +126,7 @@ namespace Microsoft.AspNet.Mvc.ViewComponents componentType.FullName)); } - private async Task InvokeCoreAsync( + private Task InvokeCoreAsync( [NotNull] TextWriter writer, [NotNull] ViewComponentDescriptor descriptor, object[] arguments) @@ -140,7 +140,7 @@ namespace Microsoft.AspNet.Mvc.ViewComponents Resources.FormatViewComponent_IViewComponentFactory_ReturnedNull(descriptor.Type.FullName)); } - await invoker.InvokeAsync(context); + return invoker.InvokeAsync(context); } private void InvokeCore( diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/ViewComponentHelperExtensions.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/ViewComponentHelperExtensions.cs index bd8bf1ed42..304ba52171 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/ViewComponentHelperExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewComponents/ViewComponentHelperExtensions.cs @@ -21,16 +21,16 @@ namespace Microsoft.AspNet.Mvc helper.RenderInvoke(typeof(TComponent), args); } - public static async Task InvokeAsync([NotNull] this IViewComponentHelper helper, + public static Task InvokeAsync([NotNull] this IViewComponentHelper helper, params object[] args) { - return await helper.InvokeAsync(typeof(TComponent), args); + return helper.InvokeAsync(typeof(TComponent), args); } - public static async Task RenderInvokeAsync([NotNull] this IViewComponentHelper helper, + public static Task RenderInvokeAsync([NotNull] this IViewComponentHelper helper, params object[] args) { - await helper.RenderInvokeAsync(typeof(TComponent), args); + return helper.RenderInvokeAsync(typeof(TComponent), args); } } } diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ActionResults/BadRequestErrorMessageResult.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ActionResults/BadRequestErrorMessageResult.cs index 143db23753..a11a7376a6 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ActionResults/BadRequestErrorMessageResult.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ActionResults/BadRequestErrorMessageResult.cs @@ -28,10 +28,10 @@ namespace System.Web.Http public string Message { get; private set; } /// - public override async Task ExecuteResultAsync(ActionContext context) + public override Task ExecuteResultAsync(ActionContext context) { context.HttpContext.Response.StatusCode = StatusCodes.Status400BadRequest; - await base.ExecuteResultAsync(context); + return base.ExecuteResultAsync(context); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ActionResults/InvalidModelStateResult.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ActionResults/InvalidModelStateResult.cs index 8171b208ca..eb8cde4e86 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ActionResults/InvalidModelStateResult.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/ActionResults/InvalidModelStateResult.cs @@ -38,10 +38,10 @@ namespace System.Web.Http public bool IncludeErrorDetail { get; private set; } /// - public override async Task ExecuteResultAsync(ActionContext context) + public override Task ExecuteResultAsync(ActionContext context) { context.HttpContext.Response.StatusCode = StatusCodes.Status400BadRequest; - await base.ExecuteResultAsync(context); + return base.ExecuteResultAsync(context); } } } \ No newline at end of file