From a5f3a6425e57f43a1d7e7ebf86553d8c35391242 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 7 Jun 2017 16:56:02 -0700 Subject: [PATCH] Remove TaskCache and TaskCacheOfT --- .../AcceptedAtActionResult.cs | 2 +- .../ActionResult.cs | 2 +- .../Filters/ExceptionFilterAttribute.cs | 3 +-- .../HttpNoContentOutputFormatter.cs | 3 +-- .../Formatters/StringOutputFormatter.cs | 4 +--- .../Formatters/TextOutputFormatter.cs | 3 +-- .../Internal/ControllerActionInvoker.cs | 6 +++--- .../Internal/MvcAttributeRouteHandler.cs | 5 ++--- .../Internal/MvcRouteHandler.cs | 6 +++--- .../Internal/NoOpBinder.cs | 2 +- .../Internal/ObjectResultExecutor.cs | 2 +- .../Internal/ResourceInvoker.cs | 10 +++++----- .../Internal/TaskCache.cs | 20 ------------------- .../Internal/TaskCacheOfT.cs | 18 ----------------- .../Binders/ByteArrayModelBinder.cs | 9 ++++----- .../Binders/CancellationTokenModelBinder.cs | 3 +-- .../Binders/ComplexTypeModelBinder.cs | 3 +-- .../ModelBinding/Binders/HeaderModelBinder.cs | 3 +-- .../Binders/ServicesModelBinder.cs | 3 +-- .../Binders/SimpleTypeModelBinder.cs | 9 ++++----- .../ModelBinding/FormValueProviderFactory.cs | 4 +--- .../JQueryFormValueProviderFactory.cs | 3 +-- .../QueryStringValueProviderFactory.cs | 3 +-- .../ModelBinding/RouteValueProviderFactory.cs | 3 +-- .../DisableCorsAuthorizationFilter.cs | 2 +- .../Internal/JsonResultExecutor.cs | 2 +- .../Internal/NullView.cs | 3 +-- .../Internal/SaveTempDataFilter.cs | 9 ++++----- .../Internal/ViewBufferTextWriter.cs | 15 +++++++------- .../ContentViewComponentResult.cs | 3 +-- .../HtmlContentViewComponentResult.cs | 3 +-- .../HttpRequestMessageModelBinder.cs | 3 +-- .../ForbidResultTest.cs | 11 +++++----- .../Internal/AttributeRouteTest.cs | 6 +++--- .../ControllerBinderDelegateProviderTest.cs | 12 +++++------ .../Internal/MiddlewareFilterTest.cs | 2 +- .../Binders/BinderTypeModelBinderTest.cs | 2 +- .../Binders/ComplexTypeModelBinderTest.cs | 2 +- .../ModelBinding/ParameterBinderTest.cs | 4 ++-- .../ModelBinding/StubModelBinder.cs | 8 ++++---- .../SignInResultTest.cs | 5 ++--- .../SignOutResultTest.cs | 7 +++---- ...nderTypeBasedModelBinderIntegrationTest.cs | 15 +++++++------- .../GenericModelBinderIntegrationTest.cs | 5 ++--- .../SimpleValueProviderFactory.cs | 2 +- .../RazorPagesWebSite/HandlerTestPage.cshtml | 9 ++++----- .../ModelHandlerTestModel.cs | 9 ++++----- 47 files changed, 100 insertions(+), 168 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Mvc.Core/Internal/TaskCache.cs delete mode 100644 src/Microsoft.AspNetCore.Mvc.Core/Internal/TaskCacheOfT.cs diff --git a/src/Microsoft.AspNetCore.Mvc.Core/AcceptedAtActionResult.cs b/src/Microsoft.AspNetCore.Mvc.Core/AcceptedAtActionResult.cs index aea31ae127..dd0480c39e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/AcceptedAtActionResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/AcceptedAtActionResult.cs @@ -4,8 +4,8 @@ using System; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Core; -using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Mvc.Routing; +using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; using Microsoft.Net.Http.Headers; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ActionResult.cs b/src/Microsoft.AspNetCore.Mvc.Core/ActionResult.cs index c9748a814f..70d2046fa2 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ActionResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ActionResult.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Mvc public virtual Task ExecuteResultAsync(ActionContext context) { ExecuteResult(context); - return TaskCache.CompletedTask; + return Task.CompletedTask; } /// diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Filters/ExceptionFilterAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/Filters/ExceptionFilterAttribute.cs index f5cface3e4..e6efec0d2e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Filters/ExceptionFilterAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Filters/ExceptionFilterAttribute.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Internal; namespace Microsoft.AspNetCore.Mvc.Filters { @@ -26,7 +25,7 @@ namespace Microsoft.AspNetCore.Mvc.Filters } OnException(context); - return TaskCache.CompletedTask; + return Task.CompletedTask; } /// diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Formatters/HttpNoContentOutputFormatter.cs b/src/Microsoft.AspNetCore.Mvc.Core/Formatters/HttpNoContentOutputFormatter.cs index 291992f5f0..244ffa829e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Formatters/HttpNoContentOutputFormatter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Formatters/HttpNoContentOutputFormatter.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc.Internal; namespace Microsoft.AspNetCore.Mvc.Formatters { @@ -43,7 +42,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters response.StatusCode = StatusCodes.Status204NoContent; } - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Formatters/StringOutputFormatter.cs b/src/Microsoft.AspNetCore.Mvc.Core/Formatters/StringOutputFormatter.cs index ca9abc9e9c..52c387d137 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Formatters/StringOutputFormatter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Formatters/StringOutputFormatter.cs @@ -5,8 +5,6 @@ using System; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc.Internal; -using Microsoft.Extensions.Primitives; namespace Microsoft.AspNetCore.Mvc.Formatters { @@ -53,7 +51,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters var valueAsString = (string)context.Object; if (string.IsNullOrEmpty(valueAsString)) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } var response = context.HttpContext.Response; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Formatters/TextOutputFormatter.cs b/src/Microsoft.AspNetCore.Mvc.Core/Formatters/TextOutputFormatter.cs index 26e07e59b3..3441c6d3f3 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Formatters/TextOutputFormatter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Formatters/TextOutputFormatter.cs @@ -7,7 +7,6 @@ using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Core; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; @@ -138,7 +137,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters { var response = context.HttpContext.Response; response.StatusCode = StatusCodes.Status406NotAcceptable; - return TaskCache.CompletedTask; + return Task.CompletedTask; } context.ContentType = selectedMediaType; diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvoker.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvoker.cs index 02f464d8f6..3318f71a5c 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvoker.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvoker.cs @@ -239,7 +239,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal } isCompleted = true; - return TaskCache.CompletedTask; + return Task.CompletedTask; } var actionExecutedContext = _actionExecutedContext; @@ -251,7 +251,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal } isCompleted = true; - return TaskCache.CompletedTask; + return Task.CompletedTask; } default: @@ -459,7 +459,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal if (actionDescriptor.BoundProperties.Count == 0 && actionDescriptor.Parameters.Count == 0) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } Debug.Assert(_cacheEntry.ControllerBinderDelegate != null); diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcAttributeRouteHandler.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcAttributeRouteHandler.cs index 9da2c28199..23f8f2c01a 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcAttributeRouteHandler.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcAttributeRouteHandler.cs @@ -4,7 +4,6 @@ using System; using System.Diagnostics; using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.Core; using Microsoft.AspNetCore.Mvc.Infrastructure; @@ -79,7 +78,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal if (actionDescriptor == null) { _logger.NoActionsMatched(context.RouteData.Values); - return TaskCache.CompletedTask; + return Task.CompletedTask; } foreach (var kvp in actionDescriptor.RouteValues) @@ -111,7 +110,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal return invoker.InvokeAsync(); }; - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcRouteHandler.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcRouteHandler.cs index d377c59f76..2c03dfdc94 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcRouteHandler.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcRouteHandler.cs @@ -67,14 +67,14 @@ namespace Microsoft.AspNetCore.Mvc.Internal if (candidates == null || candidates.Count == 0) { _logger.NoActionsMatched(context.RouteData.Values); - return TaskCache.CompletedTask; + return Task.CompletedTask; } var actionDescriptor = _actionSelector.SelectBestCandidate(context, candidates); if (actionDescriptor == null) { _logger.NoActionsMatched(context.RouteData.Values); - return TaskCache.CompletedTask; + return Task.CompletedTask; } context.Handler = (c) => @@ -98,7 +98,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal return invoker.InvokeAsync(); }; - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/NoOpBinder.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/NoOpBinder.cs index c3fc25d032..0fd7146fc3 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/NoOpBinder.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/NoOpBinder.cs @@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal public Task BindModelAsync(ModelBindingContext bindingContext) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ObjectResultExecutor.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ObjectResultExecutor.cs index fd7fff6aab..21cda3a0c9 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ObjectResultExecutor.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ObjectResultExecutor.cs @@ -149,7 +149,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal Logger.NoFormatter(formatterContext); context.HttpContext.Response.StatusCode = StatusCodes.Status406NotAcceptable; - return TaskCache.CompletedTask; + return Task.CompletedTask; } Logger.FormatterSelected(selectedFormatter, formatterContext); diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ResourceInvoker.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ResourceInvoker.cs index 2fe722031d..5536467b22 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ResourceInvoker.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ResourceInvoker.cs @@ -624,7 +624,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal if (scope == Scope.Exception) { isCompleted = true; - return TaskCache.CompletedTask; + return Task.CompletedTask; } if (exceptionContext != null) @@ -662,7 +662,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal // If we're inside an exception filter, let's allow those filters to 'unwind' before // the result. isCompleted = true; - return TaskCache.CompletedTask; + return Task.CompletedTask; } Debug.Assert(scope == Scope.Invoker || scope == Scope.Resource); @@ -847,7 +847,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal } isCompleted = true; - return TaskCache.CompletedTask; + return Task.CompletedTask; } Rethrow(_resultExecutedContext); @@ -877,7 +877,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal if (scope == Scope.Resource) { isCompleted = true; - return TaskCache.CompletedTask; + return Task.CompletedTask; } Debug.Assert(scope == Scope.Invoker); @@ -889,7 +889,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal case State.InvokeEnd: { isCompleted = true; - return TaskCache.CompletedTask; + return Task.CompletedTask; } default: diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/TaskCache.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/TaskCache.cs deleted file mode 100644 index 46f4b56e1c..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/TaskCache.cs +++ /dev/null @@ -1,20 +0,0 @@ -// 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.AspNetCore.Mvc.Internal -{ - public static class TaskCache - { - - /// - /// A that's already completed successfully. - /// - /// - /// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done - /// by Task.CompletedTask. - /// - public static readonly Task CompletedTask = Task.CompletedTask; - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/TaskCacheOfT.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/TaskCacheOfT.cs deleted file mode 100644 index 333c9d4a0d..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/TaskCacheOfT.cs +++ /dev/null @@ -1,18 +0,0 @@ -// 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.AspNetCore.Mvc.Internal -{ - public static class TaskCache - { - private static readonly Task _defaultCompletedTask = Task.FromResult(default(T)); - - /// - /// Gets a completed with the value of default(T). - /// - public static Task DefaultCompletedTask => _defaultCompletedTask; - } - -} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ByteArrayModelBinder.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ByteArrayModelBinder.cs index 6af899a099..ff7b81704f 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ByteArrayModelBinder.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ByteArrayModelBinder.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Internal; namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders { @@ -24,7 +23,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders var valueProviderResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName); if (valueProviderResult == ValueProviderResult.None) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } bindingContext.ModelState.SetModelValue(bindingContext.ModelName, valueProviderResult); @@ -33,14 +32,14 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders var value = valueProviderResult.FirstValue; if (string.IsNullOrEmpty(value)) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } try { var model = Convert.FromBase64String(value); bindingContext.Result = ModelBindingResult.Success(model); - return TaskCache.CompletedTask; + return Task.CompletedTask; } catch (Exception exception) { @@ -48,7 +47,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders bindingContext.ModelName, exception, bindingContext.ModelMetadata); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/CancellationTokenModelBinder.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/CancellationTokenModelBinder.cs index c61f837503..b8b9493ffe 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/CancellationTokenModelBinder.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/CancellationTokenModelBinder.cs @@ -5,7 +5,6 @@ using System; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; -using Microsoft.AspNetCore.Mvc.Internal; namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders { @@ -30,7 +29,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders bindingContext.ValidationState.Add(model, new ValidationStateEntry() { SuppressValidation = true }); bindingContext.Result = ModelBindingResult.Success(model); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ComplexTypeModelBinder.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ComplexTypeModelBinder.cs index f82f500b1e..828784c9dd 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ComplexTypeModelBinder.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ComplexTypeModelBinder.cs @@ -7,7 +7,6 @@ using System.Linq.Expressions; using System.Reflection; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Core; -using Microsoft.AspNetCore.Mvc.Internal; namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders { @@ -45,7 +44,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders if (!CanCreateModel(bindingContext)) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } // Perf: separated to avoid allocating a state machine when we don't diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/HeaderModelBinder.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/HeaderModelBinder.cs index 6c03799a10..f67df12864 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/HeaderModelBinder.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/HeaderModelBinder.cs @@ -4,7 +4,6 @@ using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.ModelBinding.Internal; namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders @@ -63,7 +62,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders bindingContext.Result = ModelBindingResult.Success(model); } - return TaskCache.CompletedTask; + return Task.CompletedTask; } private static object GetCompatibleCollection(ModelBindingContext bindingContext, string[] values) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ServicesModelBinder.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ServicesModelBinder.cs index 27f8cbf6e2..97fcefd1fb 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ServicesModelBinder.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ServicesModelBinder.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; using Microsoft.Extensions.DependencyInjection; @@ -29,7 +28,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders bindingContext.ValidationState.Add(model, new ValidationStateEntry() { SuppressValidation = true }); bindingContext.Result = ModelBindingResult.Success(model); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/SimpleTypeModelBinder.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/SimpleTypeModelBinder.cs index 92ab83ad2f..cdcaaedf28 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/SimpleTypeModelBinder.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/SimpleTypeModelBinder.cs @@ -5,7 +5,6 @@ using System; using System.ComponentModel; using System.Runtime.ExceptionServices; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Internal; namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders { @@ -38,7 +37,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders if (valueProviderResult == ValueProviderResult.None) { // no entry - return TaskCache.CompletedTask; + return Task.CompletedTask; } bindingContext.ModelState.SetModelValue(bindingContext.ModelName, valueProviderResult); @@ -83,12 +82,12 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders bindingContext.ModelMetadata.ModelBindingMessageProvider.ValueMustNotBeNullAccessor( valueProviderResult.ToString())); - return TaskCache.CompletedTask; + return Task.CompletedTask; } else { bindingContext.Result = ModelBindingResult.Success(model); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } catch (Exception exception) @@ -107,7 +106,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders bindingContext.ModelMetadata); // Were able to find a converter for the type but conversion failed. - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/FormValueProviderFactory.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/FormValueProviderFactory.cs index 50f4252c93..f9febdef06 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/FormValueProviderFactory.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/FormValueProviderFactory.cs @@ -4,8 +4,6 @@ using System; using System.Globalization; using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc.Internal; namespace Microsoft.AspNetCore.Mvc.ModelBinding { @@ -29,7 +27,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding return AddValueProviderAsync(context); } - return TaskCache.CompletedTask; + return Task.CompletedTask; } private static async Task AddValueProviderAsync(ValueProviderFactoryContext context) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs index e036205311..e007ea3160 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/JQueryFormValueProviderFactory.cs @@ -8,7 +8,6 @@ using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Core; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.Extensions.Primitives; namespace Microsoft.AspNetCore.Mvc.ModelBinding @@ -33,7 +32,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding return AddValueProviderAsync(context); } - return TaskCache.CompletedTask; + return Task.CompletedTask; } private static async Task AddValueProviderAsync(ValueProviderFactoryContext context) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/QueryStringValueProviderFactory.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/QueryStringValueProviderFactory.cs index bc109bcb30..435963bee5 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/QueryStringValueProviderFactory.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/QueryStringValueProviderFactory.cs @@ -4,7 +4,6 @@ using System; using System.Globalization; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Internal; namespace Microsoft.AspNetCore.Mvc.ModelBinding { @@ -29,7 +28,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding context.ValueProviders.Add(valueProvider); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/RouteValueProviderFactory.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/RouteValueProviderFactory.cs index cb1cdb4552..c87ca932dc 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/RouteValueProviderFactory.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/RouteValueProviderFactory.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Internal; namespace Microsoft.AspNetCore.Mvc.ModelBinding { @@ -26,7 +25,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding context.ValueProviders.Add(valueProvider); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Cors/Internal/DisableCorsAuthorizationFilter.cs b/src/Microsoft.AspNetCore.Mvc.Cors/Internal/DisableCorsAuthorizationFilter.cs index 732fd530d8..f87e53d5ec 100644 --- a/src/Microsoft.AspNetCore.Mvc.Cors/Internal/DisableCorsAuthorizationFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.Cors/Internal/DisableCorsAuthorizationFilter.cs @@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Mvc.Cors.Internal } // Let the action be executed. - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/JsonResultExecutor.cs b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/JsonResultExecutor.cs index e6322571ff..bce8341796 100644 --- a/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/JsonResultExecutor.cs +++ b/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/JsonResultExecutor.cs @@ -131,7 +131,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Json.Internal } } - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/NullView.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/NullView.cs index fc9a972334..6ce44ca33c 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/NullView.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/NullView.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewEngines; @@ -22,7 +21,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal throw new ArgumentNullException(nameof(context)); } - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/SaveTempDataFilter.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/SaveTempDataFilter.cs index 413a009cb3..4984a9b44d 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/SaveTempDataFilter.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/SaveTempDataFilter.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; +using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.AspNetCore.Mvc.Internal; namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal { @@ -41,10 +41,9 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal // Example: An action returns NoContentResult and since NoContentResult does not write anything to // the body of the response, this delegate would get executed way late in the pipeline at which point // the session feature would have been removed. - object obj; - if (saveTempDataContext.HttpContext.Items.TryGetValue(TempDataSavedKey, out obj)) + if (saveTempDataContext.HttpContext.Items.TryGetValue(TempDataSavedKey, out var obj)) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } SaveTempData( @@ -53,7 +52,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal filters: saveTempDataContext.Filters, httpContext: saveTempDataContext.HttpContext); - return TaskCache.CompletedTask; + return Task.CompletedTask; }, state: new SaveTempDataContext() { diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/ViewBufferTextWriter.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/ViewBufferTextWriter.cs index f011296fbe..e7d3761677 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/ViewBufferTextWriter.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Internal/ViewBufferTextWriter.cs @@ -7,7 +7,6 @@ using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNetCore.Html; -using Microsoft.AspNetCore.Mvc.Internal; namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal { @@ -253,7 +252,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal if (IsBuffering) { Buffer.AppendHtml(value.ToString()); - return TaskCache.CompletedTask; + return Task.CompletedTask; } else { @@ -281,7 +280,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal if (IsBuffering) { Buffer.AppendHtml(new string(buffer, index, count)); - return TaskCache.CompletedTask; + return Task.CompletedTask; } else { @@ -295,7 +294,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal if (IsBuffering) { Buffer.AppendHtml(value); - return TaskCache.CompletedTask; + return Task.CompletedTask; } else { @@ -337,7 +336,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal { Buffer.AppendHtml(value.ToString()); Buffer.AppendHtml(NewLine); - return TaskCache.CompletedTask; + return Task.CompletedTask; } else { @@ -352,7 +351,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal { Buffer.AppendHtml(new string(value, start, offset)); Buffer.AppendHtml(NewLine); - return TaskCache.CompletedTask; + return Task.CompletedTask; } else { @@ -367,7 +366,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal { Buffer.AppendHtml(value); Buffer.AppendHtml(NewLine); - return TaskCache.CompletedTask; + return Task.CompletedTask; } else { @@ -381,7 +380,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Internal if (IsBuffering) { Buffer.AppendHtml(NewLine); - return TaskCache.CompletedTask; + return Task.CompletedTask; } else { diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/ContentViewComponentResult.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/ContentViewComponentResult.cs index 7fc77d85c7..3f93189678 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/ContentViewComponentResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/ContentViewComponentResult.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Internal; namespace Microsoft.AspNetCore.Mvc.ViewComponents { @@ -58,7 +57,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents { Execute(context); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/HtmlContentViewComponentResult.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/HtmlContentViewComponentResult.cs index e77fa66653..e13faea8c8 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/HtmlContentViewComponentResult.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/HtmlContentViewComponentResult.cs @@ -4,7 +4,6 @@ using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Html; -using Microsoft.AspNetCore.Mvc.Internal; namespace Microsoft.AspNetCore.Mvc.ViewComponents { @@ -58,7 +57,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents { Execute(context); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageModelBinder.cs b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageModelBinder.cs index 94d22b6fde..29fd9aa437 100644 --- a/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageModelBinder.cs +++ b/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageModelBinder.cs @@ -3,7 +3,6 @@ using System.Net.Http; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; @@ -21,7 +20,7 @@ namespace Microsoft.AspNetCore.Mvc.WebApiCompatShim bindingContext.ValidationState.Add(model, new ValidationStateEntry() { SuppressValidation = true }); bindingContext.Result = ModelBindingResult.Success(model); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/ForbidResultTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/ForbidResultTest.cs index c9c895f154..0e94026c38 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/ForbidResultTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/ForbidResultTest.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -26,7 +25,7 @@ namespace Microsoft.AspNetCore.Mvc var auth = new Mock(); auth .Setup(c => c.ForbidAsync(httpContext.Object, "", null)) - .Returns(TaskCache.CompletedTask) + .Returns(Task.CompletedTask) .Verifiable(); httpContext.Setup(c => c.RequestServices).Returns(CreateServices(auth.Object)); var result = new ForbidResult("", null); @@ -53,11 +52,11 @@ namespace Microsoft.AspNetCore.Mvc var auth = new Mock(); auth .Setup(c => c.ForbidAsync(httpContext.Object, "Scheme1", authProperties)) - .Returns(TaskCache.CompletedTask) + .Returns(Task.CompletedTask) .Verifiable(); auth .Setup(c => c.ForbidAsync(httpContext.Object, "Scheme2", authProperties)) - .Returns(TaskCache.CompletedTask) + .Returns(Task.CompletedTask) .Verifiable(); httpContext.Setup(c => c.RequestServices).Returns(CreateServices(auth.Object)); var result = new ForbidResult(new[] { "Scheme1", "Scheme2" }, authProperties); @@ -91,7 +90,7 @@ namespace Microsoft.AspNetCore.Mvc var auth = new Mock(); auth .Setup(c => c.ForbidAsync(httpContext.Object, null, expected)) - .Returns(TaskCache.CompletedTask) + .Returns(Task.CompletedTask) .Verifiable(); httpContext.Setup(c => c.RequestServices).Returns(CreateServices(auth.Object)); var result = new ForbidResult(expected); @@ -119,7 +118,7 @@ namespace Microsoft.AspNetCore.Mvc var auth = new Mock(); auth .Setup(c => c.ForbidAsync(httpContext.Object, null, expected)) - .Returns(TaskCache.CompletedTask) + .Returns(Task.CompletedTask) .Verifiable(); httpContext.Setup(c => c.RequestServices).Returns(CreateServices(auth.Object)); var result = new ForbidResult(expected) diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/AttributeRouteTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/AttributeRouteTest.cs index cecd129c21..a11448fe7e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/AttributeRouteTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/AttributeRouteTest.cs @@ -69,9 +69,9 @@ namespace Microsoft.AspNetCore.Mvc.Internal selected = actions[1]; } - routeContext.Handler = (c) => TaskCache.CompletedTask; + routeContext.Handler = (c) => Task.CompletedTask; - return TaskCache.CompletedTask; + return Task.CompletedTask; }); return handler.Object; @@ -788,7 +788,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal handler .Setup(h => h.RouteAsync(It.IsAny())) .Callback(c => c.Handler = NullHandler) - .Returns(TaskCache.CompletedTask) + .Returns(Task.CompletedTask) .Verifiable(); return handler; } diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerBinderDelegateProviderTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerBinderDelegateProviderTest.cs index 434fdef05e..ef3a8a67ea 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerBinderDelegateProviderTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerBinderDelegateProviderTest.cs @@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal var binder = new Mock(); binder .Setup(b => b.BindModelAsync(It.IsAny())) - .Returns(TaskCache.CompletedTask); + .Returns(Task.CompletedTask); var factory = GetModelBinderFactory(binder.Object); var parameterBinder = GetParameterBinder(factory); @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal var binder = new Mock(); binder .Setup(b => b.BindModelAsync(It.IsAny())) - .Returns(TaskCache.CompletedTask); + .Returns(Task.CompletedTask); var factory = GetModelBinderFactory(binder.Object); var parameterBinder = GetParameterBinder(factory); @@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal context.ModelMetadata = metadataProvider.GetMetadataForType(typeof(string)); context.Result = ModelBindingResult.Success(value); }) - .Returns(TaskCache.CompletedTask); + .Returns(Task.CompletedTask); var factory = GetModelBinderFactory(binder.Object); var parameterBinder = GetParameterBinder(factory); @@ -209,7 +209,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal var binder = new Mock(); binder .Setup(b => b.BindModelAsync(It.IsAny())) - .Returns(TaskCache.CompletedTask); + .Returns(Task.CompletedTask); var mockValidator = new Mock(MockBehavior.Strict); mockValidator @@ -308,7 +308,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal var binder = new Mock(); binder .Setup(b => b.BindModelAsync(It.IsAny())) - .Returns(TaskCache.CompletedTask); + .Returns(Task.CompletedTask); var mockValidator = new Mock(MockBehavior.Strict); mockValidator @@ -821,7 +821,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal .Returns(mbc => { mbc.Result = ModelBindingResult.Success(model); - return TaskCache.CompletedTask; + return Task.CompletedTask; }); return GetModelBinderFactory(binder.Object); diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/MiddlewareFilterTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/MiddlewareFilterTest.cs index 4d09b72d6f..8524010df9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/MiddlewareFilterTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/MiddlewareFilterTest.cs @@ -475,7 +475,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal arguments.Add(entry.Key, entry.Value); } - return TaskCache.CompletedTask; + return Task.CompletedTask; } } diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/BinderTypeModelBinderTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/BinderTypeModelBinderTest.cs index b4fdc5edd7..2dee3bbf02 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/BinderTypeModelBinderTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/BinderTypeModelBinderTest.cs @@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders public Task BindModelAsync(ModelBindingContext bindingContext) { bindingContext.Result = ModelBindingResult.Success(_model); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/ComplexTypeModelBinderTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/ComplexTypeModelBinderTest.cs index 1754f257d1..4b8e1a7cae 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/ComplexTypeModelBinderTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/ComplexTypeModelBinderTest.cs @@ -1374,7 +1374,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders bindingContext.Result = result; } - return TaskCache.CompletedTask; + return Task.CompletedTask; } protected override Task BindProperty(ModelBindingContext bindingContext) diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/ParameterBinderTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/ParameterBinderTest.cs index 811e068aef..39a48657ec 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/ParameterBinderTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/ParameterBinderTest.cs @@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding { Assert.Equal(expectedModelName, context.ModelName, StringComparer.Ordinal); }) - .Returns(TaskCache.CompletedTask); + .Returns(Task.CompletedTask); var parameterDescriptor = new ParameterDescriptor { @@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding { Assert.Equal(expectedModelName, context.ModelName, StringComparer.Ordinal); }) - .Returns(TaskCache.CompletedTask); + .Returns(Task.CompletedTask); var parameterDescriptor = new ParameterDescriptor { diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/StubModelBinder.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/StubModelBinder.cs index db3d9bd2d8..790780b0e9 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/StubModelBinder.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/StubModelBinder.cs @@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding public StubModelBinder() { - _callback = context => TaskCache.CompletedTask; + _callback = context => Task.CompletedTask; } public StubModelBinder(ModelBindingResult result) @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding _callback = context => { context.Result = result; - return TaskCache.CompletedTask; + return Task.CompletedTask; }; } @@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding _callback = context => { callback(context); - return TaskCache.CompletedTask; + return Task.CompletedTask; }; } @@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding { var result = callback.Invoke(context); context.Result = result; - return TaskCache.CompletedTask; + return Task.CompletedTask; }; } diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/SignInResultTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/SignInResultTest.cs index 42e24b5a58..1b3246ccb0 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/SignInResultTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/SignInResultTest.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -28,7 +27,7 @@ namespace Microsoft.AspNetCore.Mvc var auth = new Mock(); auth .Setup(c => c.SignInAsync(httpContext.Object, "", principal, null)) - .Returns(TaskCache.CompletedTask) + .Returns(Task.CompletedTask) .Verifiable(); httpContext.Setup(c => c.RequestServices).Returns(CreateServices(auth.Object)); var result = new SignInResult("", principal, null); @@ -56,7 +55,7 @@ namespace Microsoft.AspNetCore.Mvc var auth = new Mock(); auth .Setup(c => c.SignInAsync(httpContext.Object, "Scheme1", principal, authProperties)) - .Returns(TaskCache.CompletedTask) + .Returns(Task.CompletedTask) .Verifiable(); httpContext.Setup(c => c.RequestServices).Returns(CreateServices(auth.Object)); var result = new SignInResult("Scheme1", principal, authProperties); diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/SignOutResultTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/SignOutResultTest.cs index d73bd99e6c..f2615fc841 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/SignOutResultTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/SignOutResultTest.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -26,7 +25,7 @@ namespace Microsoft.AspNetCore.Mvc var auth = new Mock(); auth .Setup(c => c.SignOutAsync(httpContext.Object, "", null)) - .Returns(TaskCache.CompletedTask) + .Returns(Task.CompletedTask) .Verifiable(); httpContext.Setup(c => c.RequestServices).Returns(CreateServices(auth.Object)); var result = new SignOutResult("", null); @@ -53,11 +52,11 @@ namespace Microsoft.AspNetCore.Mvc var auth = new Mock(); auth .Setup(c => c.SignOutAsync(httpContext.Object, "Scheme1", authProperties)) - .Returns(TaskCache.CompletedTask) + .Returns(Task.CompletedTask) .Verifiable(); auth .Setup(c => c.SignOutAsync(httpContext.Object, "Scheme2", authProperties)) - .Returns(TaskCache.CompletedTask) + .Returns(Task.CompletedTask) .Verifiable(); httpContext.Setup(c => c.RequestServices).Returns(CreateServices(auth.Object)); var result = new SignOutResult(new[] { "Scheme1", "Scheme2" }, authProperties); diff --git a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/BinderTypeBasedModelBinderIntegrationTest.cs b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/BinderTypeBasedModelBinderIntegrationTest.cs index 171e5f6def..688cbbffef 100644 --- a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/BinderTypeBasedModelBinderIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/BinderTypeBasedModelBinderIntegrationTest.cs @@ -5,7 +5,6 @@ using System; using System.Diagnostics; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Testing; using Xunit; @@ -327,7 +326,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests if (bindingContext.ModelType != typeof(Address)) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } var address = new Address() { Street = "SomeStreet" }; @@ -338,7 +337,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests address.Street); bindingContext.Result = ModelBindingResult.Success(address); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } @@ -355,7 +354,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests if (bindingContext.ModelType != typeof(Address3)) { - return TaskCache.CompletedTask; + return Task.CompletedTask; } var address = new Address3 { Street = "SomeStreet" }; @@ -366,7 +365,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests address.Street); bindingContext.Result = ModelBindingResult.Success(address); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } @@ -387,7 +386,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests model); bindingContext.Result =ModelBindingResult.Success(model); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } @@ -402,7 +401,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Debug.Assert(bindingContext.Result == ModelBindingResult.Failed()); bindingContext.Result = ModelBindingResult.Success(model: null); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } @@ -417,7 +416,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Debug.Assert(bindingContext.Result == ModelBindingResult.Failed()); bindingContext.Result = ModelBindingResult.Failed(); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/GenericModelBinderIntegrationTest.cs b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/GenericModelBinderIntegrationTest.cs index 54d73edcaf..d85638e325 100644 --- a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/GenericModelBinderIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/GenericModelBinderIntegrationTest.cs @@ -7,7 +7,6 @@ using System.Diagnostics; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.ModelBinding; using Xunit; @@ -183,11 +182,11 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests { // Binding Sources are opt-in. This model either didn't specify one or specified something // incompatible so let other binders run. - return TaskCache.CompletedTask; + return Task.CompletedTask; } bindingContext.Result = ModelBindingResult.Success(new Address()); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } diff --git a/test/Microsoft.AspNetCore.Mvc.TestCommon/SimpleValueProviderFactory.cs b/test/Microsoft.AspNetCore.Mvc.TestCommon/SimpleValueProviderFactory.cs index 443deabade..d6a1ac1d27 100644 --- a/test/Microsoft.AspNetCore.Mvc.TestCommon/SimpleValueProviderFactory.cs +++ b/test/Microsoft.AspNetCore.Mvc.TestCommon/SimpleValueProviderFactory.cs @@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding public Task CreateValueProviderAsync(ValueProviderFactoryContext context) { context.ValueProviders.Add(_valueProvider); - return TaskCache.CompletedTask; + return Task.CompletedTask; } } } diff --git a/test/WebSites/RazorPagesWebSite/HandlerTestPage.cshtml b/test/WebSites/RazorPagesWebSite/HandlerTestPage.cshtml index e5ceaf4fe7..93dcb1d6a1 100644 --- a/test/WebSites/RazorPagesWebSite/HandlerTestPage.cshtml +++ b/test/WebSites/RazorPagesWebSite/HandlerTestPage.cshtml @@ -1,6 +1,5 @@ @page "{handler?}" -@using Microsoft.AspNetCore.Mvc.Internal @using RazorPagesWebSite @functions{ @@ -13,26 +12,26 @@ public async Task OnPostAsync() { - await TaskCache.CompletedTask; + await Task.CompletedTask; MethodName = nameof(OnPostAsync); return Page(); } public async Task OnGetCustomer() { - await TaskCache.CompletedTask; + await Task.CompletedTask; MethodName = nameof(OnGetCustomer); } public async Task OnGetViewCustomerAsync() { - await TaskCache.CompletedTask; + await Task.CompletedTask; MethodName = nameof(OnGetViewCustomerAsync); } public async Task OnPostCustomActionResult() { - await TaskCache.CompletedTask; + await Task.CompletedTask; return new CustomActionResult(); } diff --git a/test/WebSites/RazorPagesWebSite/ModelHandlerTestModel.cs b/test/WebSites/RazorPagesWebSite/ModelHandlerTestModel.cs index 7d9e57388d..95e9e5ecfc 100644 --- a/test/WebSites/RazorPagesWebSite/ModelHandlerTestModel.cs +++ b/test/WebSites/RazorPagesWebSite/ModelHandlerTestModel.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.RazorPages; namespace RazorPagesWebSite @@ -19,26 +18,26 @@ namespace RazorPagesWebSite public async Task OnPostAsync() { - await TaskCache.CompletedTask; + await Task.CompletedTask; MethodName = nameof(OnPostAsync); return Page(); } public async Task OnGetCustomer() { - await TaskCache.CompletedTask; + await Task.CompletedTask; MethodName = nameof(OnGetCustomer); } public async Task OnGetViewCustomerAsync() { - await TaskCache.CompletedTask; + await Task.CompletedTask; MethodName = nameof(OnGetViewCustomerAsync); } public async Task OnPostCustomActionResult() { - await TaskCache.CompletedTask; + await Task.CompletedTask; return new CustomActionResult(); }