mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-03 11:05:56 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user