Using [NotNull]

This commit is contained in:
Hisham Abdullah Bin Ateya 2015-05-07 16:19:38 +03:00 committed by Chris R
parent 018b4c2426
commit 4852bf0c52
4 changed files with 10 additions and 30 deletions

View File

@ -12,6 +12,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.FeatureModel; using Microsoft.AspNet.FeatureModel;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.TestHost namespace Microsoft.AspNet.TestHost
{ {
@ -28,13 +29,8 @@ namespace Microsoft.AspNet.TestHost
/// Create a new handler. /// Create a new handler.
/// </summary> /// </summary>
/// <param name="next">The pipeline entry point.</param> /// <param name="next">The pipeline entry point.</param>
public ClientHandler(Func<IFeatureCollection, Task> next, PathString pathBase) public ClientHandler([NotNull] Func<IFeatureCollection, Task> next, PathString pathBase)
{ {
if (next == null)
{
throw new ArgumentNullException("next");
}
_next = next; _next = next;
// PathString.StartsWithSegments that we use below requires the base path to not end in a slash. // PathString.StartsWithSegments that we use below requires the base path to not end in a slash.
@ -53,14 +49,9 @@ namespace Microsoft.AspNet.TestHost
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
protected override async Task<HttpResponseMessage> SendAsync( protected override async Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request, [NotNull] HttpRequestMessage request,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
if (request == null)
{
throw new ArgumentNullException("request");
}
var state = new RequestState(request, _pathBase, cancellationToken); var state = new RequestState(request, _pathBase, cancellationToken);
var requestContent = request.Content ?? new StreamContent(Stream.Null); var requestContent = request.Content ?? new StreamContent(Stream.Null);
var body = await requestContent.ReadAsStreamAsync(); var body = await requestContent.ReadAsStreamAsync();

View File

@ -7,6 +7,7 @@ using System.Globalization;
using System.IO; using System.IO;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.TestHost namespace Microsoft.AspNet.TestHost
{ {
@ -26,13 +27,8 @@ namespace Microsoft.AspNet.TestHost
/// <param name="server"></param> /// <param name="server"></param>
/// <param name="path"></param> /// <param name="path"></param>
[SuppressMessage("Microsoft.Usage", "CA2234:PassSystemUriObjectsInsteadOfStrings", Justification = "Not a full URI")] [SuppressMessage("Microsoft.Usage", "CA2234:PassSystemUriObjectsInsteadOfStrings", Justification = "Not a full URI")]
public RequestBuilder(TestServer server, string path) public RequestBuilder([NotNull] TestServer server, string path)
{ {
if (server == null)
{
throw new ArgumentNullException("server");
}
_server = server; _server = server;
_req = new HttpRequestMessage(HttpMethod.Get, path); _req = new HttpRequestMessage(HttpMethod.Get, path);
} }
@ -42,13 +38,8 @@ namespace Microsoft.AspNet.TestHost
/// </summary> /// </summary>
/// <param name="configure"></param> /// <param name="configure"></param>
/// <returns></returns> /// <returns></returns>
public RequestBuilder And(Action<HttpRequestMessage> configure) public RequestBuilder And([NotNull] Action<HttpRequestMessage> configure)
{ {
if (configure == null)
{
throw new ArgumentNullException("configure");
}
configure(_req); configure(_req);
return this; return this;
} }

View File

@ -8,6 +8,7 @@ using System.Diagnostics.Contracts;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.TestHost namespace Microsoft.AspNet.TestHost
{ {
@ -28,12 +29,8 @@ namespace Microsoft.AspNet.TestHost
private Action _onFirstWrite; private Action _onFirstWrite;
private bool _firstWrite; private bool _firstWrite;
internal ResponseStream(Action onFirstWrite) internal ResponseStream([NotNull] Action onFirstWrite)
{ {
if (onFirstWrite == null)
{
throw new ArgumentNullException("onFirstWrite");
}
_onFirstWrite = onFirstWrite; _onFirstWrite = onFirstWrite;
_firstWrite = true; _firstWrite = true;

View File

@ -2,7 +2,8 @@
"version": "1.0.0-*", "version": "1.0.0-*",
"description": "ASP.NET 5 web server for writing and running tests.", "description": "ASP.NET 5 web server for writing and running tests.",
"dependencies": { "dependencies": {
"Microsoft.AspNet.Hosting": "1.0.0-*" "Microsoft.AspNet.Hosting": "1.0.0-*",
"Microsoft.Framework.NotNullAttribute.Internal": { "version": "1.0.0-*", "type": "build" }
}, },
"frameworks": { "frameworks": {
"dnx451": { "dnx451": {