diff --git a/Octokit.Tests/Clients/StatisticsClientTests.cs b/Octokit.Tests/Clients/StatisticsClientTests.cs index 2c95b86b..111534b4 100644 --- a/Octokit.Tests/Clients/StatisticsClientTests.cs +++ b/Octokit.Tests/Clients/StatisticsClientTests.cs @@ -60,7 +60,7 @@ namespace Octokit.Tests.Clients statisticsClient.GetCommitActivity("username", "repositoryName"); - client.Received().GetQueuedOperation>(expectedEndPoint, Args.CancellationToken); + client.Received().GetQueuedOperation>(expectedEndPoint, Args.CancellationToken); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs index f6a288a4..0d560f8c 100644 --- a/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Reactive.Linq; using System.Threading.Tasks; using NSubstitute; @@ -276,7 +277,7 @@ namespace Octokit.Tests.Reactive [Fact] public async Task FetchesAllCommitsForPullRequest() { - var commit = new PullRequestCommit(null, null, null, null, null, null, null, null); + var commit = new PullRequestCommit(null, null, null, null, null, Enumerable.Empty(), null, null); var expectedUrl = string.Format("repos/fake/repo/pulls/42/commits"); var gitHubClient = Substitute.For(); var connection = Substitute.For(); diff --git a/Octokit/Clients/StatisticsClient.cs b/Octokit/Clients/StatisticsClient.cs index 20b55359..5ac2cd80 100644 --- a/Octokit/Clients/StatisticsClient.cs +++ b/Octokit/Clients/StatisticsClient.cs @@ -71,7 +71,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); var endpoint = "/repos/{0}/{1}/stats/commit_activity".FormatUri(owner, repositoryName); - var activity = await ApiConnection.GetQueuedOperation>(endpoint,cancellationToken); + var activity = await ApiConnection.GetQueuedOperation>(endpoint,cancellationToken); return new CommitActivity(activity); } diff --git a/Octokit/Models/Response/CodeFrequency.cs b/Octokit/Models/Response/CodeFrequency.cs index 8aa579d0..409d81e6 100644 --- a/Octokit/Models/Response/CodeFrequency.cs +++ b/Octokit/Models/Response/CodeFrequency.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.Linq; @@ -16,7 +17,9 @@ namespace Octokit public CodeFrequency(IEnumerable additionsAndDeletionsByWeek) { - AdditionsAndDeletionsByWeek = additionsAndDeletionsByWeek; + Ensure.ArgumentNotNull(additionsAndDeletionsByWeek, "additionsAndDeletionsByWeek"); + + AdditionsAndDeletionsByWeek = new ReadOnlyCollection(additionsAndDeletionsByWeek.ToList()); } /// @@ -32,7 +35,7 @@ namespace Octokit /// /// A weekly aggregate of the number of additions and deletions pushed to a repository. /// - public IEnumerable AdditionsAndDeletionsByWeek { get; private set; } + public IReadOnlyList AdditionsAndDeletionsByWeek { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Commit.cs b/Octokit/Models/Response/Commit.cs index 3100b19e..d0b34756 100644 --- a/Octokit/Models/Response/Commit.cs +++ b/Octokit/Models/Response/Commit.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; +using System.Linq; namespace Octokit { @@ -11,11 +13,13 @@ namespace Octokit public Commit(string url, string label, string @ref, string sha, User user, Repository repository, string message, SignatureResponse author, SignatureResponse committer, GitReference tree, IEnumerable parents, int commentCount) : base(url, label, @ref, sha, user, repository) { + Ensure.ArgumentNotNull(parents, "parents"); + Message = message; Author = author; Committer = committer; Tree = tree; - Parents = parents; + Parents = new ReadOnlyCollection(parents.ToList()); CommentCount = commentCount; } @@ -27,7 +31,7 @@ namespace Octokit public GitReference Tree { get; protected set; } - public IEnumerable Parents { get; protected set; } + public IReadOnlyList Parents { get; protected set; } public int CommentCount { get; protected set; } } diff --git a/Octokit/Models/Response/CommitActivity.cs b/Octokit/Models/Response/CommitActivity.cs index 32312401..4cb7b8e5 100644 --- a/Octokit/Models/Response/CommitActivity.cs +++ b/Octokit/Models/Response/CommitActivity.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.Linq; @@ -13,13 +14,15 @@ namespace Octokit public CommitActivity(IEnumerable activity) { - Activity = activity; + Ensure.ArgumentNotNull(activity, "activity"); + + Activity = new ReadOnlyCollection(activity.ToList()); } /// /// Returns the last year of commit activity grouped by week. /// - public IEnumerable Activity { get; private set; } + public IReadOnlyList Activity { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/License.cs b/Octokit/Models/Response/License.cs index ee751e82..f68dcc60 100644 --- a/Octokit/Models/Response/License.cs +++ b/Octokit/Models/Response/License.cs @@ -76,17 +76,17 @@ namespace Octokit /// /// Set of codes for what is required under the terms of the license. For example, "include-copyright" /// - public IReadOnlyCollection Required { get; protected set; } + public IReadOnlyList Required { get; protected set; } /// /// Set of codes for what is permitted under the terms of the license. For example, "commerical-use" /// - public IReadOnlyCollection Permitted { get; protected set; } + public IReadOnlyList Permitted { get; protected set; } /// /// Set of codes for what is forbidden under the terms of the license. For example, "no-liability" /// - public IReadOnlyCollection Forbidden { get; protected set; } + public IReadOnlyList Forbidden { get; protected set; } /// /// The text of the license diff --git a/Octokit/Models/Response/Merge.cs b/Octokit/Models/Response/Merge.cs index bb5ce647..a958d4b5 100644 --- a/Octokit/Models/Response/Merge.cs +++ b/Octokit/Models/Response/Merge.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; +using System.Linq; namespace Octokit { @@ -10,10 +12,12 @@ namespace Octokit public Merge(Author author, Author committer, Commit commit, IEnumerable parents, string commentsUrl, int commentCount, string htmlUrl) { + Ensure.ArgumentNotNull(parents, "parents"); + Author = author; Committer = committer; Commit = commit; - Parents = parents; + Parents = new ReadOnlyCollection(parents.ToList()); CommentsUrl = commentsUrl; CommentCount = commentCount; HtmlUrl = htmlUrl; @@ -22,7 +26,7 @@ namespace Octokit public Author Author { get; protected set; } public Author Committer { get; protected set; } public Commit Commit { get; protected set; } - public IEnumerable Parents { get; protected set; } + public IReadOnlyList Parents { get; protected set; } public string CommentsUrl { get; protected set; } public int CommentCount { get; protected set; } public string HtmlUrl { get; protected set; } diff --git a/Octokit/Models/Response/Participation.cs b/Octokit/Models/Response/Participation.cs index 215acc25..e054dc35 100644 --- a/Octokit/Models/Response/Participation.cs +++ b/Octokit/Models/Response/Participation.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.Linq; @@ -16,19 +17,22 @@ namespace Octokit public Participation(IEnumerable all, IEnumerable owner) { - All = all; - Owner = owner; + Ensure.ArgumentNotNull(all, "all"); + Ensure.ArgumentNotNull(owner, "owner"); + + All = new ReadOnlyCollection(all.ToList()); + Owner = new ReadOnlyCollection(owner.ToList()); } /// /// Returns the commit counts made each week, for the last 52 weeks /// - public IEnumerable All { get; protected set; } + public IReadOnlyList All { get; protected set; } /// /// Returns the commit counts made by the owner each week, for the last 52 weeks /// - public IEnumerable Owner { get; protected set; } + public IReadOnlyList Owner { get; protected set; } /// /// The total number of commits made by the owner in the last 52 weeks. diff --git a/Octokit/Models/Response/PullRequestCommit.cs b/Octokit/Models/Response/PullRequestCommit.cs index 0d99e29f..94c2d330 100644 --- a/Octokit/Models/Response/PullRequestCommit.cs +++ b/Octokit/Models/Response/PullRequestCommit.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; +using System.Linq; namespace Octokit { @@ -12,12 +14,14 @@ namespace Octokit public PullRequestCommit(SignatureResponse author, Uri commentsUrl, Commit commit, SignatureResponse committer, Uri htmlUrl, IEnumerable parents, string sha, Uri url) { + Ensure.ArgumentNotNull(parents, "parents"); + Author = author; CommentsUrl = commentsUrl; Commit = commit; Committer = committer; HtmlUrl = htmlUrl; - Parents = parents; + Parents = new ReadOnlyCollection(parents.ToList()); Sha = sha; Url = url; } @@ -32,7 +36,7 @@ namespace Octokit public Uri HtmlUrl { get; protected set; } - public IEnumerable Parents { get; protected set; } + public IReadOnlyList Parents { get; protected set; } public string Sha { get; protected set; } diff --git a/Octokit/Models/Response/WeeklyCommitActivity.cs b/Octokit/Models/Response/WeeklyCommitActivity.cs index 505a5bc2..d3d40313 100644 --- a/Octokit/Models/Response/WeeklyCommitActivity.cs +++ b/Octokit/Models/Response/WeeklyCommitActivity.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.Linq; @@ -14,7 +15,9 @@ namespace Octokit public WeeklyCommitActivity(IEnumerable days, int total, long week) { - Days = days; + Ensure.ArgumentNotNull(days, "days"); + + Days = new ReadOnlyCollection(days.ToList()); Total = total; Week = week; } @@ -22,7 +25,7 @@ namespace Octokit /// /// The days array is a group of commits per day, starting on Sunday. /// - public IEnumerable Days { get; protected set; } + public IReadOnlyList Days { get; protected set; } /// /// Totally number of commits made this week.