Add null checks and fix CodeAnalysis errors.

I enabled code analysis to the Octokit.Reactive project and
needed to fix things up.
This commit is contained in:
Haacked
2013-01-29 14:36:24 -08:00
parent 997e955f38
commit e07b6d62c2
17 changed files with 87 additions and 3 deletions
+18
View File
@@ -26,28 +26,39 @@ namespace Octokit.Http
public async Task<T> Get(Uri endpoint)
{
Ensure.ArgumentNotNull(endpoint, "endpoint");
return await GetItem<T>(endpoint);
}
public async Task<TOther> GetItem<TOther>(Uri endpoint)
{
Ensure.ArgumentNotNull(endpoint, "endpoint");
var response = await Connection.GetAsync<TOther>(endpoint);
return response.BodyAsObject;
}
public async Task<string> GetHtml(Uri endpoint)
{
Ensure.ArgumentNotNull(endpoint, "endpoint");
var response = await Connection.GetHtml(endpoint);
return response.Body;
}
public async Task<IReadOnlyCollection<T>> GetAll(Uri endpoint)
{
Ensure.ArgumentNotNull(endpoint, "endpoint");
return await pagination.GetAllPages(async () => await GetPage(endpoint));
}
public async Task<T> Create(Uri endpoint, object data)
{
Ensure.ArgumentNotNull(endpoint, "endpoint");
Ensure.ArgumentNotNull(data, "data");
var response = await Connection.PostAsync<T>(endpoint, data);
return response.BodyAsObject;
@@ -55,6 +66,9 @@ namespace Octokit.Http
public async Task<T> Update(Uri endpoint, object data)
{
Ensure.ArgumentNotNull(endpoint, "endpoint");
Ensure.ArgumentNotNull(data, "data");
var response = await Connection.PatchAsync<T>(endpoint, data);
return response.BodyAsObject;
@@ -62,11 +76,15 @@ namespace Octokit.Http
public async Task Delete(Uri endpoint)
{
Ensure.ArgumentNotNull(endpoint, "endpoint");
await Connection.DeleteAsync<T>(endpoint);
}
async Task<IReadOnlyPagedCollection<T>> GetPage(Uri endpoint)
{
Ensure.ArgumentNotNull(endpoint, "endpoint");
var response = await Connection.GetAsync<List<T>>(endpoint);
return new ReadOnlyPagedCollection<T>(response, Connection);
}