diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index 4784be35b8..4c1020f1be 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -1343,6 +1343,30 @@ public async Task GetsLanguagesWithRepositoryId() Assert.NotEmpty(languages); Assert.True(languages.Any(l => l.Name == "C#")); } + + [IntegrationTest] + public async Task GetsEmptyLanguagesWhenNone() + { + var github = Helper.GetAuthenticatedClient(); + using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + { + var languages = await github.Repository.GetAllLanguages(context.RepositoryOwner, context.RepositoryName); + + Assert.Empty(languages); + } + } + + [IntegrationTest] + public async Task GetsEmptyLanguagesWhenNoneWithRepositoryId() + { + var github = Helper.GetAuthenticatedClient(); + using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + { + var languages = await github.Repository.GetAllLanguages(context.RepositoryId); + + Assert.Empty(languages); + } + } } public class TheGetAllTagsMethod diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 558f4828cf..b31065710e 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -693,7 +693,8 @@ public async Task> GetAllLanguages(string owne var data = await ApiConnection.Get>(endpoint).ConfigureAwait(false); return new ReadOnlyCollection( - data.Select(kvp => new RepositoryLanguage(kvp.Key, kvp.Value)).ToList()); + (data ?? new Dictionary()) + .Select(kvp => new RepositoryLanguage(kvp.Key, kvp.Value)).ToList()); } /// @@ -710,7 +711,8 @@ public async Task> GetAllLanguages(long reposi var data = await ApiConnection.Get>(endpoint).ConfigureAwait(false); return new ReadOnlyCollection( - data.Select(kvp => new RepositoryLanguage(kvp.Key, kvp.Value)).ToList()); + (data ?? new Dictionary()) + .Select(kvp => new RepositoryLanguage(kvp.Key, kvp.Value)).ToList()); } ///