diff --git a/Octokit.Tests.Integration/UsersClientTests.cs b/Octokit.Tests.Integration/UsersClientTests.cs index 21f1f465..5ef006e4 100644 --- a/Octokit.Tests.Integration/UsersClientTests.cs +++ b/Octokit.Tests.Integration/UsersClientTests.cs @@ -1,4 +1,5 @@ -using System.Net; +using System.Linq; +using System.Net; using System.Net.Http.Headers; using System.Reactive.Linq; using System.Threading.Tasks; @@ -110,10 +111,10 @@ namespace Octokit.Tests.Integration var emails = await github.User.GetEmails(); - Assert.Equal(1, emails.Count); - Assert.Equal("test-octowin@example.com", emails[0].Email); - Assert.True(emails[0].Primary); - Assert.False(emails[0].Verified); + Assert.Equal(1, emails.Count()); + Assert.Equal("test-octowin@example.com", emails.First().Email); + Assert.True(emails.First().Primary); + Assert.False(emails.First().Verified); } } } diff --git a/Octokit.Tests/Clients/UsersClientTests.cs b/Octokit.Tests/Clients/UsersClientTests.cs index a3d4fb41..660ec381 100644 --- a/Octokit.Tests/Clients/UsersClientTests.cs +++ b/Octokit.Tests/Clients/UsersClientTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; #if NET_45 using System.Collections.ObjectModel; #endif @@ -101,7 +102,7 @@ namespace Octokit.Tests.Clients usersClient.GetEmails(); - client.Received().Get>(endpoint, null); + client.Received().Get>(endpoint, null); } } } diff --git a/Octokit/Clients/AssigneesClient.cs b/Octokit/Clients/AssigneesClient.cs index b0dea000..998d74d8 100644 --- a/Octokit/Clients/AssigneesClient.cs +++ b/Octokit/Clients/AssigneesClient.cs @@ -16,12 +16,12 @@ namespace Octokit /// The owner of the repository /// The name of the repository /// - public async Task> GetForRepository(string owner, string name) + public Task> GetForRepository(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return await ApiConnection.GetAll(ApiUrls.Assignees(owner, name)); + return ApiConnection.GetAll(ApiUrls.Assignees(owner, name)); } /// diff --git a/Octokit/Clients/AuthorizationsClient.cs b/Octokit/Clients/AuthorizationsClient.cs index 0490b8fc..1d3adfd6 100644 --- a/Octokit/Clients/AuthorizationsClient.cs +++ b/Octokit/Clients/AuthorizationsClient.cs @@ -52,10 +52,10 @@ namespace Octokit /// /// Thrown when a general API error occurs. /// The specified . - public async Task Get(int id) + public Task Get(int id) { var endpoint = "authorizations/{0}".FormatUri(id); - return await ApiConnection.Get(endpoint); + return ApiConnection.Get(endpoint); } /// @@ -77,7 +77,7 @@ namespace Octokit /// /// Thrown when a general API error occurs. /// The created . - public async Task GetOrCreateApplicationAuthentication( + public Task GetOrCreateApplicationAuthentication( string clientId, string clientSecret, NewAuthorization newAuthorization) @@ -95,7 +95,7 @@ namespace Octokit note_url = newAuthorization.NoteUrl }; - return await ApiConnection.Put(endpoint, requestData); + return ApiConnection.Put(endpoint, requestData); } /// @@ -118,7 +118,7 @@ namespace Octokit /// /// Thrown when a general API error occurs. /// The created . - public async Task GetOrCreateApplicationAuthentication( + public Task GetOrCreateApplicationAuthentication( string clientId, string clientSecret, NewAuthorization newAuthorization, @@ -140,7 +140,7 @@ namespace Octokit try { - return await ApiConnection.Put( + return ApiConnection.Put( endpoint, requestData, twoFactorAuthenticationCode); @@ -166,12 +166,12 @@ namespace Octokit /// /// Thrown when a general API error occurs. /// The updated . - public async Task Update(int id, AuthorizationUpdate authorizationUpdate) + public Task Update(int id, AuthorizationUpdate authorizationUpdate) { Ensure.ArgumentNotNull(authorizationUpdate, "authorizationUpdate"); var endpoint = "authorizations/{0}".FormatUri(id); - return await ApiConnection.Patch(endpoint, authorizationUpdate); + return ApiConnection.Patch(endpoint, authorizationUpdate); } /// @@ -187,11 +187,11 @@ namespace Octokit /// /// Thrown when a general API error occurs. /// The created . - public async Task Create(NewAuthorization newAuthorization) + public Task Create(NewAuthorization newAuthorization) { Ensure.ArgumentNotNull(newAuthorization, "newAuthorization"); - return await ApiConnection.Post(ApiUrls.Authorizations(), newAuthorization); + return ApiConnection.Post(ApiUrls.Authorizations(), newAuthorization); } /// @@ -208,10 +208,10 @@ namespace Octokit /// /// Thrown when a general API error occurs. /// A for the request's execution. - public async Task Delete(int id) + public Task Delete(int id) { var endpoint = "authorizations/{0}".FormatUri(id); - await ApiConnection.Delete(endpoint); + return ApiConnection.Delete(endpoint); } } } diff --git a/Octokit/Clients/INotificationsClient.cs b/Octokit/Clients/INotificationsClient.cs index fe870b0c..241295f2 100644 --- a/Octokit/Clients/INotificationsClient.cs +++ b/Octokit/Clients/INotificationsClient.cs @@ -12,13 +12,13 @@ namespace Octokit /// Thrown if the client is not authenticated. /// A of . [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - Task> GetAllForCurrent(); + Task> GetAllForCurrent(); /// /// Retrieves all of the s for the current user specific to the specified repository. /// /// Thrown if the client is not authenticated. /// A of . - Task> GetAllForRepository(string owner, string name); + Task> GetAllForRepository(string owner, string name); } } diff --git a/Octokit/Clients/IUsersClient.cs b/Octokit/Clients/IUsersClient.cs index 824a4325..6e96c525 100644 --- a/Octokit/Clients/IUsersClient.cs +++ b/Octokit/Clients/IUsersClient.cs @@ -34,6 +34,6 @@ namespace Octokit /// /// [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - Task> GetEmails(); + Task> GetEmails(); } } diff --git a/Octokit/Clients/MilestonesClient.cs b/Octokit/Clients/MilestonesClient.cs index efcea301..d30c3e28 100644 --- a/Octokit/Clients/MilestonesClient.cs +++ b/Octokit/Clients/MilestonesClient.cs @@ -18,13 +18,12 @@ namespace Octokit /// http://developer.github.com/v3/Milestones/#get-a-single-Milestone /// /// - public async Task Get(string owner, string name, int number) + public Task Get(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return await ApiConnection.Get(ApiUrls.Milestone(owner, name, number)); - + return ApiConnection.Get(ApiUrls.Milestone(owner, name, number)); } /// @@ -36,9 +35,9 @@ namespace Octokit /// The owner of the repository /// The name of the repository /// - public async Task> GetForRepository(string owner, string name) + public Task> GetForRepository(string owner, string name) { - return await GetForRepository(owner, name, new MilestoneRequest()); + return GetForRepository(owner, name, new MilestoneRequest()); } /// @@ -51,13 +50,13 @@ namespace Octokit /// The name of the repository /// Used to filter and sort the list of Milestones returned /// - public async Task> GetForRepository(string owner, string name, MilestoneRequest request) + public Task> GetForRepository(string owner, string name, MilestoneRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); - return await ApiConnection.GetAll(ApiUrls.Milestones(owner, name), + return ApiConnection.GetAll(ApiUrls.Milestones(owner, name), request.ToParametersDictionary()); } @@ -70,13 +69,13 @@ namespace Octokit /// The name of the repository /// A instance describing the new Milestone to create /// - public async Task Create(string owner, string name, NewMilestone newMilestone) + public Task Create(string owner, string name, NewMilestone newMilestone) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(newMilestone, "newMilestone"); - return await ApiConnection.Post(ApiUrls.Milestones(owner, name), newMilestone); + return ApiConnection.Post(ApiUrls.Milestones(owner, name), newMilestone); } /// @@ -90,13 +89,13 @@ namespace Octokit /// An instance describing the changes to make to the Milestone /// /// - public async Task Update(string owner, string name, int number, MilestoneUpdate milestoneUpdate) + public Task Update(string owner, string name, int number, MilestoneUpdate milestoneUpdate) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(milestoneUpdate, "milestoneUpdate"); - return await ApiConnection.Patch(ApiUrls.Milestone(owner, name, number), milestoneUpdate); + return ApiConnection.Patch(ApiUrls.Milestone(owner, name, number), milestoneUpdate); } /// @@ -108,12 +107,12 @@ namespace Octokit /// The name of the repository /// The milestone number /// - public async Task Delete(string owner, string name, int number) + public Task Delete(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - await ApiConnection.Delete(ApiUrls.Milestone(owner, name, number)); + return ApiConnection.Delete(ApiUrls.Milestone(owner, name, number)); } } } diff --git a/Octokit/Clients/NotificationsClient.cs b/Octokit/Clients/NotificationsClient.cs index 0898a29f..ab2fcf36 100644 --- a/Octokit/Clients/NotificationsClient.cs +++ b/Octokit/Clients/NotificationsClient.cs @@ -15,9 +15,9 @@ namespace Octokit /// /// Thrown if the client is not authenticated. /// A of . - public async Task> GetAllForCurrent() + public Task> GetAllForCurrent() { - return await ApiConnection.GetAll(ApiUrls.Notifications()); + return ApiConnection.GetAll(ApiUrls.Notifications()); } /// @@ -25,9 +25,9 @@ namespace Octokit /// /// Thrown if the client is not authenticated. /// A of . - public async Task> GetAllForRepository(string owner, string name) + public Task> GetAllForRepository(string owner, string name) { - return await ApiConnection.GetAll(ApiUrls.Notifications(owner, name)); + return ApiConnection.GetAll(ApiUrls.Notifications(owner, name)); } } } diff --git a/Octokit/Clients/OrganizationsClient.cs b/Octokit/Clients/OrganizationsClient.cs index c457b6bd..f5c443d5 100644 --- a/Octokit/Clients/OrganizationsClient.cs +++ b/Octokit/Clients/OrganizationsClient.cs @@ -28,12 +28,12 @@ namespace Octokit /// login of the organization to get. /// Thrown when a general API error occurs. /// The specified . - public async Task Get(string org) + public Task Get(string org) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); var endpoint = "orgs/{0}".FormatUri(org); - return await ApiConnection.Get(endpoint); + return ApiConnection.Get(endpoint); } /// @@ -41,9 +41,9 @@ namespace Octokit /// /// Thrown when a general API error occurs. /// A list of the current user's s. - public async Task> GetAllForCurrent() + public Task> GetAllForCurrent() { - return await ApiConnection.GetAll(ApiUrls.Organizations()); + return ApiConnection.GetAll(ApiUrls.Organizations()); } /// @@ -51,11 +51,11 @@ namespace Octokit /// /// Thrown when a general API error occurs. /// A list of the specified user's s. - public async Task> GetAll(string user) + public Task> GetAll(string user) { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return await ApiConnection.GetAll(ApiUrls.Organizations(user)); + return ApiConnection.GetAll(ApiUrls.Organizations(user)); } } } diff --git a/Octokit/Clients/ReleasesClient.cs b/Octokit/Clients/ReleasesClient.cs index 73863c92..408a4955 100644 --- a/Octokit/Clients/ReleasesClient.cs +++ b/Octokit/Clients/ReleasesClient.cs @@ -31,13 +31,13 @@ namespace Octokit /// The repository's name. /// Thrown when a general API error occurs. /// The list of s for the specified repository. - public async Task> GetAll(string owner, string name) + public Task> GetAll(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "repository"); var endpoint = ApiUrls.Releases(owner, name); - return await ApiConnection.GetAll(endpoint, null, "application/vnd.github.manifold-preview"); + return ApiConnection.GetAll(endpoint, null, "application/vnd.github.manifold-preview"); } /// @@ -51,14 +51,14 @@ namespace Octokit /// A description of the release to create. /// Thrown when a general API error occurs. /// The created . - public async Task CreateRelease(string owner, string name, ReleaseUpdate data) + public Task CreateRelease(string owner, string name, ReleaseUpdate data) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "repository"); Ensure.ArgumentNotNull(data, "data"); var endpoint = ApiUrls.Releases(owner, name); - return await ApiConnection.Post(endpoint, data, "application/vnd.github.manifold-preview"); + return ApiConnection.Post(endpoint, data, "application/vnd.github.manifold-preview"); } /// @@ -71,13 +71,13 @@ namespace Octokit /// Description of the asset with its data. /// Thrown when a general API error occurs. /// The created . - public async Task UploadAsset(Release release, ReleaseAssetUpload data) + public Task UploadAsset(Release release, ReleaseAssetUpload data) { Ensure.ArgumentNotNull(release, "release"); Ensure.ArgumentNotNull(data, "data"); var endpoint = release.UploadUrl.ExpandUriTemplate(new {name = data.FileName}); - return await ApiConnection.Post( + return ApiConnection.Post( endpoint, data.RawData, "application/vnd.github.manifold-preview", diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index d960e0d1..f23bf445 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -32,13 +32,13 @@ namespace Octokit /// A instance describing the new repository to create. /// Thrown when a general API error occurs. /// A instance for the created repository. - public async Task Create(NewRepository newRepository) + public Task Create(NewRepository newRepository) { Ensure.ArgumentNotNull(newRepository, "newRepository"); if (string.IsNullOrEmpty(newRepository.Name)) throw new ArgumentException("The new repository's name must not be null."); - return await ApiConnection.Post(ApiUrls.Repositories(), newRepository); + return ApiConnection.Post(ApiUrls.Repositories(), newRepository); } /// @@ -51,14 +51,14 @@ namespace Octokit /// A instance describing the new repository to create. /// Thrown when a general API error occurs. /// A instance for the created repository - public async Task Create(string organizationLogin, NewRepository newRepository) + public Task Create(string organizationLogin, NewRepository newRepository) { Ensure.ArgumentNotNull(organizationLogin, "organizationLogin"); Ensure.ArgumentNotNull(newRepository, "newRepository"); if (string.IsNullOrEmpty(newRepository.Name)) throw new ArgumentException("The new repository's name must not be null."); - return await ApiConnection.Post(ApiUrls.OrganizationRepositories(organizationLogin), newRepository); + return ApiConnection.Post(ApiUrls.OrganizationRepositories(organizationLogin), newRepository); } /// @@ -71,13 +71,13 @@ namespace Octokit /// The owner of the repository. /// The name of the repository. /// Thrown when a general API error occurs. - public async Task Delete(string owner, string name) + public Task Delete(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); var endpoint = "repos/{0}/{1}".FormatUri(owner, name); - await ApiConnection.Delete(endpoint); + return ApiConnection.Delete(endpoint); } /// @@ -90,13 +90,13 @@ namespace Octokit /// The name of the repository. /// Thrown when a general API error occurs. /// A - public async Task Get(string owner, string name) + public Task Get(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); var endpoint = "repos/{0}/{1}".FormatUri(owner, name); - return await ApiConnection.Get(endpoint); + return ApiConnection.Get(endpoint); } /// @@ -109,9 +109,9 @@ namespace Octokit /// Thrown if the client is not authenticated. /// Thrown when a general API error occurs. /// A of . - public async Task> GetAllForCurrent() + public Task> GetAllForCurrent() { - return await ApiConnection.GetAll(ApiUrls.Repositories()); + return ApiConnection.GetAll(ApiUrls.Repositories()); } /// @@ -123,11 +123,11 @@ namespace Octokit /// /// Thrown when a general API error occurs. /// A of . - public async Task> GetAllForUser(string login) + public Task> GetAllForUser(string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); - return await ApiConnection.GetAll(ApiUrls.Repositories(login)); + return ApiConnection.GetAll(ApiUrls.Repositories(login)); } /// @@ -139,11 +139,11 @@ namespace Octokit /// /// Thrown when a general API error occurs. /// A of . - public async Task> GetAllForOrg(string organization) + public Task> GetAllForOrg(string organization) { Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); - return await ApiConnection.GetAll(ApiUrls.OrganizationRepositories(organization)); + return ApiConnection.GetAll(ApiUrls.OrganizationRepositories(organization)); } /// @@ -176,13 +176,13 @@ namespace Octokit /// The name of the repository. /// Thrown when a general API error occurs. /// - public async Task GetReadmeHtml(string owner, string name) + public Task GetReadmeHtml(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); var endpoint = "repos/{0}/{1}/readme".FormatUri(owner, name); - return await ApiConnection.GetHtml(endpoint, null); + return ApiConnection.GetHtml(endpoint, null); } /// diff --git a/Octokit/Clients/SshKeysClient.cs b/Octokit/Clients/SshKeysClient.cs index e7765eac..4b3c8f89 100644 --- a/Octokit/Clients/SshKeysClient.cs +++ b/Octokit/Clients/SshKeysClient.cs @@ -12,45 +12,45 @@ namespace Octokit { } - public async Task Get(int id) + public Task Get(int id) { var endpoint = "user/keys/{0}".FormatUri(id); - return await ApiConnection.Get(endpoint); + return ApiConnection.Get(endpoint); } - public async Task> GetAll(string user) + public Task> GetAll(string user) { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return await ApiConnection.GetAll(ApiUrls.SshKeys(user)); + return ApiConnection.GetAll(ApiUrls.SshKeys(user)); } - public async Task> GetAllForCurrent() + public Task> GetAllForCurrent() { - return await ApiConnection.GetAll(ApiUrls.SshKeys()); + return ApiConnection.GetAll(ApiUrls.SshKeys()); } - public async Task Create(SshKeyUpdate key) + public Task Create(SshKeyUpdate key) { Ensure.ArgumentNotNull(key, "key"); - return await ApiConnection.Post(ApiUrls.SshKeys(), key); + return ApiConnection.Post(ApiUrls.SshKeys(), key); } - public async Task Update(int id, SshKeyUpdate key) + public Task Update(int id, SshKeyUpdate key) { Ensure.ArgumentNotNull(key, "key"); var endpoint = "user/keys/{0}".FormatUri(id); - return await ApiConnection.Patch(endpoint, key); + return ApiConnection.Patch(endpoint, key); } - public async Task Delete(int id) + public Task Delete(int id) { var endpoint = "user/keys/{0}".FormatUri(id); - await ApiConnection.Delete(endpoint); + return ApiConnection.Delete(endpoint); } } } diff --git a/Octokit/Clients/UsersClient.cs b/Octokit/Clients/UsersClient.cs index f8d063f1..cb53c7d5 100644 --- a/Octokit/Clients/UsersClient.cs +++ b/Octokit/Clients/UsersClient.cs @@ -25,12 +25,12 @@ namespace Octokit /// /// Optional GitHub login (username) /// A - public async Task Get(string login) + public Task Get(string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); var endpoint = "users/{0}".FormatUri(login); - return await ApiConnection.Get(endpoint); + return ApiConnection.Get(endpoint); } /// @@ -38,9 +38,9 @@ namespace Octokit /// /// Thrown if the client is not authenticated. /// A - public async Task Current() + public Task Current() { - return await ApiConnection.Get(_userEndpoint); + return ApiConnection.Get(_userEndpoint); } /// @@ -49,20 +49,20 @@ namespace Octokit /// /// Thrown if the client is not authenticated. /// A - public async Task Update(UserUpdate user) + public Task Update(UserUpdate user) { Ensure.ArgumentNotNull(user, "user"); - return await ApiConnection.Patch(_userEndpoint, user); + return ApiConnection.Patch(_userEndpoint, user); } /// /// Returns emails for the current user. /// /// - public async Task> GetEmails() + public Task> GetEmails() { - return await ApiConnection.Get>(ApiUrls.Emails(), null); + return ApiConnection.Get>(ApiUrls.Emails(), null); } } }