mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 19:46:07 +00:00
some more cleanup of unnecessary async/await
This commit is contained in:
@@ -34,9 +34,9 @@ namespace Octokit
|
||||
/// </exception>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A list of <see cref="Authorization"/>s.</returns>
|
||||
public async Task<IReadOnlyList<Authorization>> GetAll()
|
||||
public Task<IReadOnlyList<Authorization>> GetAll()
|
||||
{
|
||||
return await ApiConnection.GetAll<Authorization>(ApiUrls.Authorizations());
|
||||
return ApiConnection.GetAll<Authorization>(ApiUrls.Authorizations());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -23,12 +23,12 @@ namespace Octokit
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
/// <returns></returns>
|
||||
public async Task<Issue> Get(string owner, string name, int number)
|
||||
public Task<Issue> Get(string owner, string name, int number)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return await ApiConnection.Get<Issue>(ApiUrls.Issue(owner, name, number));
|
||||
return ApiConnection.Get<Issue>(ApiUrls.Issue(owner, name, number));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -40,9 +40,9 @@ namespace Octokit
|
||||
/// http://developer.github.com/v3/issues/#list-issues
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
public async Task<IReadOnlyList<Issue>> GetAllForCurrent()
|
||||
public Task<IReadOnlyList<Issue>> GetAllForCurrent()
|
||||
{
|
||||
return await GetAllForCurrent(new IssueRequest());
|
||||
return GetAllForCurrent(new IssueRequest());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -54,11 +54,11 @@ namespace Octokit
|
||||
/// </remarks>
|
||||
/// <param name="request">Used to filter and sort the list of issues returned</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IReadOnlyList<Issue>> GetAllForCurrent(IssueRequest request)
|
||||
public Task<IReadOnlyList<Issue>> GetAllForCurrent(IssueRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return await ApiConnection.GetAll<Issue>(ApiUrls.Issues(), request.ToParametersDictionary());
|
||||
return ApiConnection.GetAll<Issue>(ApiUrls.Issues(), request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -70,9 +70,9 @@ namespace Octokit
|
||||
/// http://developer.github.com/v3/issues/#list-issues
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
public async Task<IReadOnlyList<Issue>> GetAllForOwnedAndMemberRepositories()
|
||||
public Task<IReadOnlyList<Issue>> GetAllForOwnedAndMemberRepositories()
|
||||
{
|
||||
return await GetAllForOwnedAndMemberRepositories(new IssueRequest());
|
||||
return GetAllForOwnedAndMemberRepositories(new IssueRequest());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -83,11 +83,11 @@ namespace Octokit
|
||||
/// </remarks>
|
||||
/// <param name="request">Used to filter and sort the list of issues returned</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IReadOnlyList<Issue>> GetAllForOwnedAndMemberRepositories(IssueRequest request)
|
||||
public Task<IReadOnlyList<Issue>> GetAllForOwnedAndMemberRepositories(IssueRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return await ApiConnection.GetAll<Issue>(ApiUrls.IssuesForOwnedAndMember(),
|
||||
return ApiConnection.GetAll<Issue>(ApiUrls.IssuesForOwnedAndMember(),
|
||||
request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ namespace Octokit
|
||||
/// </remarks>
|
||||
/// <param name="organization">The name of the organization</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IReadOnlyList<Issue>> GetAllForOrganization(string organization)
|
||||
public Task<IReadOnlyList<Issue>> GetAllForOrganization(string organization)
|
||||
{
|
||||
return await GetAllForOrganization(organization, new IssueRequest());
|
||||
return GetAllForOrganization(organization, new IssueRequest());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -113,9 +113,12 @@ namespace Octokit
|
||||
/// <param name="organization">The name of the organization</param>
|
||||
/// <param name="request">Used to filter and sort the list of issues returned</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IReadOnlyList<Issue>> GetAllForOrganization(string organization, IssueRequest request)
|
||||
public Task<IReadOnlyList<Issue>> GetAllForOrganization(string organization, IssueRequest request)
|
||||
{
|
||||
return await ApiConnection.GetAll<Issue>(ApiUrls.Issues(organization), request.ToParametersDictionary());
|
||||
Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return ApiConnection.GetAll<Issue>(ApiUrls.Issues(organization), request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -127,9 +130,9 @@ namespace Octokit
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IReadOnlyList<Issue>> GetForRepository(string owner, string name)
|
||||
public Task<IReadOnlyList<Issue>> GetForRepository(string owner, string name)
|
||||
{
|
||||
return await GetForRepository(owner, name, new RepositoryIssueRequest());
|
||||
return GetForRepository(owner, name, new RepositoryIssueRequest());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -142,14 +145,14 @@ namespace Octokit
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="request">Used to filter and sort the list of issues returned</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IReadOnlyList<Issue>> GetForRepository(string owner, string name,
|
||||
public Task<IReadOnlyList<Issue>> GetForRepository(string owner, string name,
|
||||
RepositoryIssueRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return await ApiConnection.GetAll<Issue>(ApiUrls.Issues(owner, name), request.ToParametersDictionary());
|
||||
return ApiConnection.GetAll<Issue>(ApiUrls.Issues(owner, name), request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -161,13 +164,13 @@ namespace Octokit
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="newIssue">A <see cref="NewIssue"/> instance describing the new issue to create</param>
|
||||
/// <returns></returns>
|
||||
public async Task<Issue> Create(string owner, string name, NewIssue newIssue)
|
||||
public Task<Issue> Create(string owner, string name, NewIssue newIssue)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(newIssue, "newIssue");
|
||||
|
||||
return await ApiConnection.Post<Issue>(ApiUrls.Issues(owner, name), newIssue);
|
||||
return ApiConnection.Post<Issue>(ApiUrls.Issues(owner, name), newIssue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -181,13 +184,13 @@ namespace Octokit
|
||||
/// <param name="issueUpdate">An <see cref="IssueUpdate"/> instance describing the changes to make to the issue
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public async Task<Issue> Update(string owner, string name, int number, IssueUpdate issueUpdate)
|
||||
public Task<Issue> Update(string owner, string name, int number, IssueUpdate issueUpdate)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(issueUpdate, "issueUpdate");
|
||||
|
||||
return await ApiConnection.Patch<Issue>(ApiUrls.Issue(owner, name, number), issueUpdate);
|
||||
return ApiConnection.Patch<Issue>(ApiUrls.Issue(owner, name, number), issueUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,12 +40,12 @@ namespace Octokit
|
||||
return connection.GetHtml(uri, null);
|
||||
}
|
||||
|
||||
public static async Task<IResponse<T>> GetAsync<T>(this IConnection connection, Uri uri)
|
||||
public static Task<IResponse<T>> GetAsync<T>(this IConnection connection, Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
return await connection.GetAsync<T>(uri, null, null);
|
||||
return connection.GetAsync<T>(uri, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ namespace Octokit
|
||||
/// <param name="uri">URI of the API resource to get.</param>
|
||||
/// <returns><see cref="IReadOnlyList{T}"/> of the The API resources in the list.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public async Task<IReadOnlyList<T>> GetAll<T>(Uri uri)
|
||||
public Task<IReadOnlyList<T>> GetAll<T>(Uri uri)
|
||||
{
|
||||
return await GetAll<T>(uri, null, null);
|
||||
return GetAll<T>(uri, null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -91,9 +91,9 @@ namespace Octokit
|
||||
/// <param name="parameters">Parameters to add to the API request.</param>
|
||||
/// <returns><see cref="IReadOnlyList{T}"/> of the The API resources in the list.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public async Task<IReadOnlyList<T>> GetAll<T>(Uri uri, IDictionary<string, string> parameters)
|
||||
public Task<IReadOnlyList<T>> GetAll<T>(Uri uri, IDictionary<string, string> parameters)
|
||||
{
|
||||
return await GetAll<T>(uri, parameters, null);
|
||||
return GetAll<T>(uri, parameters, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -105,11 +105,11 @@ namespace Octokit
|
||||
/// <param name="accepts">Accept header to use for the API request.</param>
|
||||
/// <returns><see cref="IReadOnlyList{T}"/> of the The API resources in the list.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public async Task<IReadOnlyList<T>> GetAll<T>(Uri uri, IDictionary<string, string> parameters, string accepts)
|
||||
public Task<IReadOnlyList<T>> GetAll<T>(Uri uri, IDictionary<string, string> parameters, string accepts)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
return await _pagination.GetAllPages(async () => await GetPage<T>(uri, parameters, accepts));
|
||||
return _pagination.GetAllPages(async () => await GetPage<T>(uri, parameters, accepts));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -120,12 +120,12 @@ namespace Octokit
|
||||
/// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body.</param>
|
||||
/// <returns>The created API resource.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public async Task<T> Post<T>(Uri uri, object data)
|
||||
public Task<T> Post<T>(Uri uri, object data)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
Ensure.ArgumentNotNull(data, "data");
|
||||
|
||||
return await Post<T>(uri, data, null, null);
|
||||
return Post<T>(uri, data, null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -137,9 +137,9 @@ namespace Octokit
|
||||
/// <param name="accepts">Accept header to use for the API request.</param>
|
||||
/// <returns>The created API resource.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public async Task<T> Post<T>(Uri uri, object data, string accepts)
|
||||
public Task<T> Post<T>(Uri uri, object data, string accepts)
|
||||
{
|
||||
return await Post<T>(uri, data, accepts, null);
|
||||
return Post<T>(uri, data, accepts, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -226,11 +226,11 @@ namespace Octokit
|
||||
/// </summary>
|
||||
/// <param name="uri">URI of the API resource to delete.</param>
|
||||
/// <returns>A <see cref="Task"/> for the request's execution.</returns>
|
||||
public async Task Delete(Uri uri)
|
||||
public Task Delete(Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
await Connection.DeleteAsync(uri);
|
||||
return Connection.DeleteAsync(uri);
|
||||
}
|
||||
|
||||
async Task<IReadOnlyPagedCollection<T>> GetPage<T>(
|
||||
|
||||
+18
-19
@@ -117,18 +117,18 @@ namespace Octokit
|
||||
_jsonPipeline = new JsonHttpPipeline();
|
||||
}
|
||||
|
||||
public async Task<IResponse<T>> GetAsync<T>(Uri uri, IDictionary<string, string> parameters, string accepts)
|
||||
public Task<IResponse<T>> GetAsync<T>(Uri uri, IDictionary<string, string> parameters, string accepts)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
return await SendData<T>(uri.ApplyParameters(parameters), HttpMethod.Get, null, accepts, null);
|
||||
return SendData<T>(uri.ApplyParameters(parameters), HttpMethod.Get, null, accepts, null);
|
||||
}
|
||||
|
||||
public async Task<IResponse<string>> GetHtml(Uri uri, IDictionary<string, string> parameters)
|
||||
public Task<IResponse<string>> GetHtml(Uri uri, IDictionary<string, string> parameters)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
return await GetHtml(new Request
|
||||
return GetHtml(new Request
|
||||
{
|
||||
Method = HttpMethod.Get,
|
||||
BaseAddress = BaseAddress,
|
||||
@@ -136,30 +136,30 @@ namespace Octokit
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<IResponse<T>> PatchAsync<T>(Uri uri, object body)
|
||||
public Task<IResponse<T>> PatchAsync<T>(Uri uri, object body)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
Ensure.ArgumentNotNull(body, "body");
|
||||
|
||||
return await SendData<T>(uri, HttpVerb.Patch, body, null, null);
|
||||
return SendData<T>(uri, HttpVerb.Patch, body, null, null);
|
||||
}
|
||||
|
||||
public async Task<IResponse<T>> PostAsync<T>(Uri uri, object body, string accepts, string contentType)
|
||||
public Task<IResponse<T>> PostAsync<T>(Uri uri, object body, string accepts, string contentType)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
Ensure.ArgumentNotNull(body, "body");
|
||||
|
||||
return await SendData<T>(uri, HttpMethod.Post, body, accepts, contentType);
|
||||
return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType);
|
||||
}
|
||||
|
||||
public async Task<IResponse<T>> PutAsync<T>(Uri uri, object body)
|
||||
public Task<IResponse<T>> PutAsync<T>(Uri uri, object body)
|
||||
{
|
||||
return await SendData<T>(uri, HttpMethod.Put, body, null, null);
|
||||
return SendData<T>(uri, HttpMethod.Put, body, null, null);
|
||||
}
|
||||
|
||||
public async Task<IResponse<T>> PutAsync<T>(Uri uri, object body, string twoFactorAuthenticationCode)
|
||||
public Task<IResponse<T>> PutAsync<T>(Uri uri, object body, string twoFactorAuthenticationCode)
|
||||
{
|
||||
return await SendData<T>(uri,
|
||||
return SendData<T>(uri,
|
||||
HttpMethod.Put,
|
||||
body,
|
||||
null,
|
||||
@@ -167,7 +167,7 @@ namespace Octokit
|
||||
twoFactorAuthenticationCode);
|
||||
}
|
||||
|
||||
async Task<IResponse<T>> SendData<T>(
|
||||
Task<IResponse<T>> SendData<T>(
|
||||
Uri uri,
|
||||
HttpMethod method,
|
||||
object body,
|
||||
@@ -202,14 +202,14 @@ namespace Octokit
|
||||
request.ContentType = contentType ?? "application/x-www-form-urlencoded";
|
||||
}
|
||||
|
||||
return await Run<T>(request);
|
||||
return Run<T>(request);
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(Uri uri)
|
||||
public Task DeleteAsync(Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
await Run<object>(new Request
|
||||
return Run<object>(new Request
|
||||
{
|
||||
Method = HttpMethod.Delete,
|
||||
BaseAddress = BaseAddress,
|
||||
@@ -251,10 +251,10 @@ namespace Octokit
|
||||
}
|
||||
}
|
||||
|
||||
async Task<IResponse<string>> GetHtml(IRequest request)
|
||||
Task<IResponse<string>> GetHtml(IRequest request)
|
||||
{
|
||||
request.Headers.Add("Accept", "application/vnd.github.html");
|
||||
return await RunRequest<string>(request);
|
||||
return RunRequest<string>(request);
|
||||
}
|
||||
|
||||
async Task<IResponse<T>> Run<T>(IRequest request)
|
||||
@@ -287,7 +287,6 @@ namespace Octokit
|
||||
|
||||
static void HandleErrors(IResponse response)
|
||||
{
|
||||
|
||||
Func<IResponse, Exception> exceptionFunc;
|
||||
if (_httpExceptionMap.TryGetValue(response.StatusCode, out exceptionFunc))
|
||||
{
|
||||
|
||||
@@ -32,9 +32,9 @@ namespace Octokit
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
|
||||
Justification = "Makse a network request")]
|
||||
public async Task<string> GetHtmlContent()
|
||||
public Task<string> GetHtmlContent()
|
||||
{
|
||||
return await htmlContent.Value;
|
||||
return htmlContent.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user