Cleanup namespaces and Task.FromResult
This commit is contained in:
parent
414c009b80
commit
9de86892a7
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc.HeaderValueAbstractions;
|
||||
|
||||
|
|
@ -21,7 +20,10 @@ namespace Microsoft.AspNet.Mvc
|
|||
return context.Object == null;
|
||||
}
|
||||
|
||||
public IReadOnlyList<MediaTypeHeaderValue> GetSupportedContentTypes(Type declaredType, Type runtimeType, MediaTypeHeaderValue contentType)
|
||||
public IReadOnlyList<MediaTypeHeaderValue> GetSupportedContentTypes(
|
||||
Type declaredType,
|
||||
Type runtimeType,
|
||||
MediaTypeHeaderValue contentType)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
@ -35,7 +37,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
// TODO: By default the status code is set to 200.
|
||||
// https://github.com/aspnet/HttpAbstractions/issues/114
|
||||
response.StatusCode = 204;
|
||||
return Task.FromResult<bool>(true);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
var response = context.ActionContext.HttpContext.Response;
|
||||
response.StatusCode = 406;
|
||||
return Task.FromResult<bool>(true);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
}
|
||||
else
|
||||
{
|
||||
return Task.FromResult<object>(result);
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ namespace Microsoft.AspNet.Mvc.Test
|
|||
{
|
||||
public Task ExecuteResultAsync(ActionContext context)
|
||||
{
|
||||
return Task.FromResult<object>(null);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
var mockInvoker = new Mock<IActionInvoker>();
|
||||
mockInvoker.Setup(i => i.InvokeAsync())
|
||||
.Returns(Task.FromResult<object>(null));
|
||||
.Returns(Task.FromResult(true));
|
||||
|
||||
var mockInvokerFactory = new Mock<IActionInvokerFactory>();
|
||||
mockInvokerFactory.Setup(f => f.CreateInvoker(It.IsAny<ActionContext>()))
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
var filter = new Mock<IAsyncExceptionFilter>(MockBehavior.Strict);
|
||||
filter
|
||||
.Setup(f => f.OnExceptionAsync(It.IsAny<ExceptionContext>()))
|
||||
.Returns<ExceptionContext>((context) => Task.FromResult<object>(null))
|
||||
.Returns<ExceptionContext>((context) => Task.FromResult(true))
|
||||
.Verifiable();
|
||||
|
||||
var invoker = CreateInvoker(filter.Object, actionThrows: false);
|
||||
|
|
@ -119,7 +119,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
// Handle the exception
|
||||
context.Result = new EmptyResult();
|
||||
})
|
||||
.Returns<ExceptionContext>((context) => Task.FromResult<object>(null))
|
||||
.Returns<ExceptionContext>((context) => Task.FromResult(true))
|
||||
.Verifiable();
|
||||
|
||||
var invoker = CreateInvoker(filter.Object, actionThrows: true);
|
||||
|
|
@ -177,7 +177,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
filter2.ToString();
|
||||
context.Exception = null;
|
||||
})
|
||||
.Returns<ExceptionContext>((context) => Task.FromResult<object>(null))
|
||||
.Returns<ExceptionContext>((context) => Task.FromResult(true))
|
||||
.Verifiable();
|
||||
|
||||
var invoker = CreateInvoker(new IFilter[] { filter1.Object, filter2.Object }, actionThrows: true);
|
||||
|
|
@ -216,7 +216,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
var result = new Mock<IActionResult>(MockBehavior.Strict);
|
||||
result
|
||||
.Setup(r => r.ExecuteResultAsync(It.IsAny<ActionContext>()))
|
||||
.Returns<ActionContext>((context) => Task.FromResult<object>(null))
|
||||
.Returns<ActionContext>((context) => Task.FromResult(true))
|
||||
.Verifiable();
|
||||
|
||||
var filter = new Mock<IExceptionFilter>(MockBehavior.Strict);
|
||||
|
|
@ -260,7 +260,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
var filter = new Mock<IAsyncAuthorizationFilter>(MockBehavior.Strict);
|
||||
filter
|
||||
.Setup(f => f.OnAuthorizationAsync(It.IsAny<AuthorizationContext>()))
|
||||
.Returns<AuthorizationContext>(context => Task.FromResult<object>(null))
|
||||
.Returns<AuthorizationContext>(context => Task.FromResult(true))
|
||||
.Verifiable();
|
||||
|
||||
var invoker = CreateInvoker(filter.Object);
|
||||
|
|
@ -309,7 +309,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
.Returns<AuthorizationContext>((context) =>
|
||||
{
|
||||
context.Result = challenge;
|
||||
return Task.FromResult<object>(null);
|
||||
return Task.FromResult(true);
|
||||
})
|
||||
.Verifiable();
|
||||
|
||||
|
|
@ -380,7 +380,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
var challenge = new Mock<IActionResult>(MockBehavior.Strict);
|
||||
challenge
|
||||
.Setup(r => r.ExecuteResultAsync(It.IsAny<ActionContext>()))
|
||||
.Returns<ActionContext>((context) => Task.FromResult<object>(null))
|
||||
.Returns<ActionContext>((context) => Task.FromResult(true))
|
||||
.Verifiable();
|
||||
|
||||
var authorizationFilter = new Mock<IAuthorizationFilter>(MockBehavior.Strict);
|
||||
|
|
@ -528,7 +528,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
// Notice we're not calling next
|
||||
c.Result = result;
|
||||
return Task.FromResult<object>(null);
|
||||
return Task.FromResult(true);
|
||||
})
|
||||
.Verifiable();
|
||||
|
||||
|
|
@ -583,7 +583,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
.Returns<ActionExecutingContext, ActionExecutionDelegate>((c, next) =>
|
||||
{
|
||||
// Notice we're not calling next
|
||||
return Task.FromResult<object>(null);
|
||||
return Task.FromResult(true);
|
||||
})
|
||||
.Verifiable();
|
||||
|
||||
|
|
@ -772,7 +772,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
var result = new Mock<IActionResult>(MockBehavior.Strict);
|
||||
result
|
||||
.Setup(r => r.ExecuteResultAsync(It.IsAny<ActionContext>()))
|
||||
.Returns<ActionContext>((context) => Task.FromResult<object>(null))
|
||||
.Returns<ActionContext>((context) => Task.FromResult(true))
|
||||
.Verifiable();
|
||||
|
||||
var actionFilter = new Mock<IActionFilter>(MockBehavior.Strict);
|
||||
|
|
@ -906,7 +906,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
// Not calling next here
|
||||
c.Cancel = true;
|
||||
return Task.FromResult<object>(null);
|
||||
return Task.FromResult(true);
|
||||
})
|
||||
.Verifiable();
|
||||
|
||||
|
|
@ -948,7 +948,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
.Returns<ResultExecutingContext, ResultExecutionDelegate>((c, next) =>
|
||||
{
|
||||
// Not calling next here
|
||||
return Task.FromResult<object>(null);
|
||||
return Task.FromResult(true);
|
||||
})
|
||||
.Verifiable();
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ using Microsoft.Framework.OptionsModel;
|
|||
using Microsoft.Framework.Logging;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using Microsoft.AspNet.PipelineCore;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.Routing
|
||||
{
|
||||
|
|
@ -1302,7 +1301,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
context.IsHandled = MatchingDelegate(context);
|
||||
}
|
||||
|
||||
return Task.FromResult<object>(null);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace ApiExplorer
|
|||
[HttpGet]
|
||||
public Task GetTask()
|
||||
{
|
||||
return Task.FromResult<object>(null);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
|
@ -65,7 +65,7 @@ namespace ApiExplorer
|
|||
[HttpGet]
|
||||
public Task<ObjectResult> GetTaskOfDerivedActionResult()
|
||||
{
|
||||
return Task.FromResult<ObjectResult>(new ObjectResult(null));
|
||||
return Task.FromResult(new ObjectResult(null));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace ConnegWebsite
|
|||
|
||||
public Task<object> ReturnTaskOfObject_ObjectValue()
|
||||
{
|
||||
return Task.FromResult<object>(new object());
|
||||
return Task.FromResult(new object());
|
||||
}
|
||||
|
||||
public string ReturnString()
|
||||
|
|
|
|||
Loading…
Reference in New Issue