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

Commit

Permalink
Remove TaskCache and TaskCacheOfT
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavkm committed Jun 8, 2017
1 parent 8662422 commit a5f3a64
Show file tree
Hide file tree
Showing 47 changed files with 100 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.AspNetCore.Mvc.Core/ActionResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class ActionResult : IActionResult
public virtual Task ExecuteResultAsync(ActionContext context)
{
ExecuteResult(context);
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Internal;

namespace Microsoft.AspNetCore.Mvc.Filters
{
Expand All @@ -26,7 +25,7 @@ public virtual Task OnExceptionAsync(ExceptionContext context)
}

OnException(context);
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Internal;

namespace Microsoft.AspNetCore.Mvc.Formatters
{
Expand Down Expand Up @@ -43,7 +42,7 @@ public Task WriteAsync(OutputFormatterWriteContext context)
response.StatusCode = StatusCodes.Status204NoContent;
}

return TaskCache.CompletedTask;
return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
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
{
Expand Down Expand Up @@ -53,7 +51,7 @@ public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context,
var valueAsString = (string)context.Object;
if (string.IsNullOrEmpty(valueAsString))
{
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

var response = context.HttpContext.Response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
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;

Expand Down Expand Up @@ -138,7 +137,7 @@ public override Task WriteAsync(OutputFormatterWriteContext context)
{
var response = context.HttpContext.Response;
response.StatusCode = StatusCodes.Status406NotAcceptable;
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

context.ContentType = selectedMediaType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private Task Next(ref State next, ref Scope scope, ref object state, ref bool is
}

isCompleted = true;
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

var actionExecutedContext = _actionExecutedContext;
Expand All @@ -251,7 +251,7 @@ private Task Next(ref State next, ref Scope scope, ref object state, ref bool is
}

isCompleted = true;
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

default:
Expand Down Expand Up @@ -459,7 +459,7 @@ private Task BindArgumentsAsync()
if (actionDescriptor.BoundProperties.Count == 0 &&
actionDescriptor.Parameters.Count == 0)
{
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

Debug.Assert(_cacheEntry.ControllerBinderDelegate != null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -79,7 +78,7 @@ public Task RouteAsync(RouteContext context)
if (actionDescriptor == null)
{
_logger.NoActionsMatched(context.RouteData.Values);
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

foreach (var kvp in actionDescriptor.RouteValues)
Expand Down Expand Up @@ -111,7 +110,7 @@ public Task RouteAsync(RouteContext context)
return invoker.InvokeAsync();
};

return TaskCache.CompletedTask;
return Task.CompletedTask;
}
}
}
6 changes: 3 additions & 3 deletions src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcRouteHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ public Task RouteAsync(RouteContext context)
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) =>
Expand All @@ -98,7 +98,7 @@ public Task RouteAsync(RouteContext context)
return invoker.InvokeAsync();
};

return TaskCache.CompletedTask;
return Task.CompletedTask;
}
}
}
2 changes: 1 addition & 1 deletion src/Microsoft.AspNetCore.Mvc.Core/Internal/NoOpBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class NoOpBinder : IModelBinder

public Task BindModelAsync(ModelBindingContext bindingContext)
{
return TaskCache.CompletedTask;
return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public virtual Task ExecuteAsync(ActionContext context, ObjectResult result)
Logger.NoFormatter(formatterContext);

context.HttpContext.Response.StatusCode = StatusCodes.Status406NotAcceptable;
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

Logger.FormatterSelected(selectedFormatter, formatterContext);
Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.AspNetCore.Mvc.Core/Internal/ResourceInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ private Task Next(ref State next, ref Scope scope, ref object state, ref bool is
if (scope == Scope.Exception)
{
isCompleted = true;
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

if (exceptionContext != null)
Expand Down Expand Up @@ -662,7 +662,7 @@ private Task Next(ref State next, ref Scope scope, ref object state, ref bool is
// 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);
Expand Down Expand Up @@ -847,7 +847,7 @@ private Task Next(ref State next, ref Scope scope, ref object state, ref bool is
}

isCompleted = true;
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

Rethrow(_resultExecutedContext);
Expand Down Expand Up @@ -877,7 +877,7 @@ private Task Next(ref State next, ref Scope scope, ref object state, ref bool is
if (scope == Scope.Resource)
{
isCompleted = true;
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

Debug.Assert(scope == Scope.Invoker);
Expand All @@ -889,7 +889,7 @@ private Task Next(ref State next, ref Scope scope, ref object state, ref bool is
case State.InvokeEnd:
{
isCompleted = true;
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

default:
Expand Down
20 changes: 0 additions & 20 deletions src/Microsoft.AspNetCore.Mvc.Core/Internal/TaskCache.cs

This file was deleted.

18 changes: 0 additions & 18 deletions src/Microsoft.AspNetCore.Mvc.Core/Internal/TaskCacheOfT.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Internal;

namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
{
Expand All @@ -24,7 +23,7 @@ public Task BindModelAsync(ModelBindingContext bindingContext)
var valueProviderResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
if (valueProviderResult == ValueProviderResult.None)
{
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

bindingContext.ModelState.SetModelValue(bindingContext.ModelName, valueProviderResult);
Expand All @@ -33,22 +32,22 @@ public Task BindModelAsync(ModelBindingContext bindingContext)
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)
{
bindingContext.ModelState.TryAddModelError(
bindingContext.ModelName,
exception,
bindingContext.ModelMetadata);
return TaskCache.CompletedTask;
return Task.CompletedTask;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.AspNetCore.Mvc.Internal;

namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
{
Expand All @@ -30,7 +29,7 @@ public Task BindModelAsync(ModelBindingContext bindingContext)
bindingContext.ValidationState.Add(model, new ValidationStateEntry() { SuppressValidation = true });
bindingContext.Result = ModelBindingResult.Success(model);

return TaskCache.CompletedTask;
return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Core;
using Microsoft.AspNetCore.Mvc.Internal;

namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
{
Expand Down Expand Up @@ -45,7 +44,7 @@ public Task BindModelAsync(ModelBindingContext bindingContext)

if (!CanCreateModel(bindingContext))
{
return TaskCache.CompletedTask;
return Task.CompletedTask;
}

// Perf: separated to avoid allocating a state machine when we don't
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -63,7 +62,7 @@ public Task BindModelAsync(ModelBindingContext bindingContext)
bindingContext.Result = ModelBindingResult.Success(model);
}

return TaskCache.CompletedTask;
return Task.CompletedTask;
}

private static object GetCompatibleCollection(ModelBindingContext bindingContext, string[] values)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -29,7 +28,7 @@ public Task BindModelAsync(ModelBindingContext bindingContext)
bindingContext.ValidationState.Add(model, new ValidationStateEntry() { SuppressValidation = true });

bindingContext.Result = ModelBindingResult.Success(model);
return TaskCache.CompletedTask;
return Task.CompletedTask;
}
}
}
Loading

0 comments on commit a5f3a64

Please sign in to comment.