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