Return IReadOnlyList over IReadOnlyCollection

ReadOnlyCollection implements IReadOnlyList. Whodathunkit?
This commit is contained in:
Haacked
2013-10-04 10:10:30 -07:00
parent adfb50198e
commit f6c156f371
28 changed files with 54 additions and 49 deletions
@@ -16,7 +16,7 @@ namespace Octokit.Reactive.Clients
_client = client;
}
public IObservable<IReadOnlyCollection<Authorization>> GetAll()
public IObservable<IReadOnlyList<Authorization>> GetAll()
{
return _client.GetAll().ToObservable();
}
@@ -22,12 +22,12 @@ namespace Octokit.Reactive.Clients
return _client.Get(org).ToObservable();
}
public IObservable<IReadOnlyCollection<Organization>> GetAllForCurrent()
public IObservable<IReadOnlyList<Organization>> GetAllForCurrent()
{
return _client.GetAllForCurrent().ToObservable();
}
public IObservable<IReadOnlyCollection<Organization>> GetAll(string user)
public IObservable<IReadOnlyList<Organization>> GetAll(string user)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
@@ -23,19 +23,19 @@ namespace Octokit.Reactive.Clients
return _client.Get(owner, name).ToObservable();
}
public IObservable<IReadOnlyCollection<Repository>> GetAllForCurrent()
public IObservable<IReadOnlyList<Repository>> GetAllForCurrent()
{
return _client.GetAllForCurrent().ToObservable();
}
public IObservable<IReadOnlyCollection<Repository>> GetAllForUser(string login)
public IObservable<IReadOnlyList<Repository>> GetAllForUser(string login)
{
Ensure.ArgumentNotNullOrEmptyString(login, "login");
return _client.GetAllForUser(login).ToObservable();
}
public IObservable<IReadOnlyCollection<Repository>> GetAllForOrg(string organization)
public IObservable<IReadOnlyList<Repository>> GetAllForOrg(string organization)
{
Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
@@ -21,14 +21,14 @@ namespace Octokit.Reactive.Clients
return _client.Get(id).ToObservable();
}
public IObservable<IReadOnlyCollection<SshKey>> GetAll(string user)
public IObservable<IReadOnlyList<SshKey>> GetAll(string user)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
return _client.GetAll(user).ToObservable();
}
public IObservable<IReadOnlyCollection<SshKey>> GetAllForCurrent()
public IObservable<IReadOnlyList<SshKey>> GetAllForCurrent()
{
return _client.GetAllForCurrent().ToObservable();
}
@@ -9,7 +9,7 @@ namespace Octokit.Reactive
{
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "It's an API call, so it's not a property.")]
IObservable<IReadOnlyCollection<Authorization>> GetAll();
IObservable<IReadOnlyList<Authorization>> GetAll();
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
Justification = "It's fiiiine. It's fine. Trust us.")]
IObservable<Authorization> Get(int id);
@@ -21,13 +21,13 @@ namespace Octokit.Reactive
/// <returns></returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Method makes a network request")]
IObservable<IReadOnlyCollection<Organization>> GetAllForCurrent();
IObservable<IReadOnlyList<Organization>> GetAllForCurrent();
/// <summary>
/// Returns all the organizations for the specified user
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
IObservable<IReadOnlyCollection<Organization>> GetAll(string user);
IObservable<IReadOnlyList<Organization>> GetAll(string user);
}
}
@@ -25,7 +25,7 @@ namespace Octokit.Reactive
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
IObservable<IReadOnlyCollection<Repository>> GetAllForCurrent();
IObservable<IReadOnlyList<Repository>> GetAllForCurrent();
/// <summary>
/// Retrieves every <see cref="Repository"/> that belongs to the specified user.
@@ -36,7 +36,7 @@ namespace Octokit.Reactive
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
IObservable<IReadOnlyCollection<Repository>> GetAllForUser(string login);
IObservable<IReadOnlyList<Repository>> GetAllForUser(string login);
/// <summary>
/// Retrieves every <see cref="Repository"/> that belongs to the specified organization.
@@ -47,7 +47,7 @@ namespace Octokit.Reactive
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
IObservable<IReadOnlyCollection<Repository>> GetAllForOrg(string organization);
IObservable<IReadOnlyList<Repository>> GetAllForOrg(string organization);
/// <summary>
/// Returns the HTML rendered README.
+2 -2
View File
@@ -20,7 +20,7 @@ namespace Octokit.Reactive
/// </summary>
/// <param name="user">The login of the user.</param>
/// <returns>A <see cref="IReadOnlyPagedCollection{SshKey}"/> of <see cref="SshKey"/>.</returns>
IObservable<IReadOnlyCollection<SshKey>> GetAll(string user);
IObservable<IReadOnlyList<SshKey>> GetAll(string user);
/// <summary>
/// Retrieves the <see cref="SshKey"/> for the specified id.
@@ -29,7 +29,7 @@ namespace Octokit.Reactive
/// <returns>A <see cref="IReadOnlyPagedCollection{SshKey}"/> of <see cref="SshKey"/>.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
IObservable<IReadOnlyCollection<SshKey>> GetAllForCurrent();
IObservable<IReadOnlyList<SshKey>> GetAllForCurrent();
/// <summary>
/// Update the specified <see cref="UserUpdate"/>.
+4 -1
View File
@@ -1,4 +1,7 @@
using System;
#if NET_45
using System.Collections.Generic;
#endif
using System.Threading.Tasks;
using Octokit.Http;
@@ -14,7 +17,7 @@ namespace Octokit
return connection.Get(endpoint, null);
}
public static Task<IReadOnlyCollection<T>> GetAll<T>(this IApiConnection<T> connection, Uri endpoint)
public static Task<IReadOnlyList<T>> GetAll<T>(this IApiConnection<T> connection, Uri endpoint)
{
Ensure.ArgumentNotNull(connection, "connection");
Ensure.ArgumentNotNull(endpoint, "endpoint");
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Octokit.Clients
/// <typeparam name="T"></typeparam>
public class ApiPagination<T> : IApiPagination<T>
{
public async Task<IReadOnlyCollection<T>> GetAllPages(Func<Task<IReadOnlyPagedCollection<T>>> getFirstPage)
public async Task<IReadOnlyList<T>> GetAllPages(Func<Task<IReadOnlyPagedCollection<T>>> getFirstPage)
{
Ensure.ArgumentNotNull(getFirstPage, "getFirstPage");
+1 -1
View File
@@ -17,7 +17,7 @@ namespace Octokit.Clients
/// Get all <see cref="Authorization"/>s for the authenticated user. This method requires basic auth.
/// </summary>
/// <returns>An <see cref="Authorization"/></returns>
public async Task<IReadOnlyCollection<Authorization>> GetAll()
public async Task<IReadOnlyList<Authorization>> GetAll()
{
return await Client.GetAll(authorizationsEndpoint);
}
+2 -2
View File
@@ -19,14 +19,14 @@ namespace Octokit.Clients
return await Client.Get(endpoint);
}
public async Task<IReadOnlyCollection<Organization>> GetAllForCurrent()
public async Task<IReadOnlyList<Organization>> GetAllForCurrent()
{
var endpoint = new Uri("/user/orgs", UriKind.Relative);
return await Client.GetAll(endpoint);
}
public async Task<IReadOnlyCollection<Organization>> GetAll(string user)
public async Task<IReadOnlyList<Organization>> GetAll(string user)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
+1 -1
View File
@@ -10,7 +10,7 @@ namespace Octokit.Clients
{
}
public async Task<IReadOnlyCollection<Release>> GetAll(string owner, string name)
public async Task<IReadOnlyList<Release>> GetAll(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "repository");
+3 -3
View File
@@ -20,13 +20,13 @@ namespace Octokit.Clients
return await Client.Get(endpoint);
}
public async Task<IReadOnlyCollection<Repository>> GetAllForCurrent()
public async Task<IReadOnlyList<Repository>> GetAllForCurrent()
{
var endpoint = new Uri("user/repos", UriKind.Relative);
return await Client.GetAll(endpoint);
}
public async Task<IReadOnlyCollection<Repository>> GetAllForUser(string login)
public async Task<IReadOnlyList<Repository>> GetAllForUser(string login)
{
Ensure.ArgumentNotNullOrEmptyString(login, "login");
@@ -35,7 +35,7 @@ namespace Octokit.Clients
return await Client.GetAll(endpoint);
}
public async Task<IReadOnlyCollection<Repository>> GetAllForOrg(string organization)
public async Task<IReadOnlyList<Repository>> GetAllForOrg(string organization)
{
Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
+2 -2
View File
@@ -18,7 +18,7 @@ namespace Octokit.Clients
return await Client.Get(endpoint);
}
public async Task<IReadOnlyCollection<SshKey>> GetAll(string user)
public async Task<IReadOnlyList<SshKey>> GetAll(string user)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
@@ -27,7 +27,7 @@ namespace Octokit.Clients
return await Client.GetAll(endpoint);
}
public async Task<IReadOnlyCollection<SshKey>> GetAllForCurrent()
public async Task<IReadOnlyList<SshKey>> GetAllForCurrent()
{
var endpoint = new Uri("/user/keys", UriKind.Relative);
+1 -1
View File
@@ -34,7 +34,7 @@ namespace Octokit
{
readonly List<TItem> _source;
public ReadOnlyCollection(IEnumerable<TItem> source)
public ReadOnlyCollection(IList<TItem> source)
{
_source = new List<TItem>(source);
}
+1 -1
View File
@@ -48,7 +48,7 @@ namespace Octokit.Http
return response.Body;
}
public async Task<IReadOnlyCollection<T>> GetAll(Uri endpoint, IDictionary<string, string> parameters)
public async Task<IReadOnlyList<T>> GetAll(Uri endpoint, IDictionary<string, string> parameters)
{
Ensure.ArgumentNotNull(endpoint, "endpoint");
+6 -4
View File
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
#if NET_45
using System.Collections.ObjectModel;
#endif
namespace Octokit.Http
{
@@ -10,8 +12,8 @@ namespace Octokit.Http
public class ApiInfo
{
public ApiInfo(IDictionary<string, Uri> links,
IEnumerable<string> oauthScopes,
IEnumerable<string> acceptedOauthScopes,
IList<string> oauthScopes,
IList<string> acceptedOauthScopes,
string etag,
int rateLimit,
int rateLimitRemaining)
@@ -30,12 +32,12 @@ namespace Octokit.Http
/// <summary>
/// Oauth scopes that were included in the token used to make the request.
/// </summary>
public IReadOnlyCollection<string> OauthScopes { get; private set; }
public IReadOnlyList<string> OauthScopes { get; private set; }
/// <summary>
/// Oauth scopes accepted for this particular call.
/// </summary>
public IReadOnlyCollection<string> AcceptedOauthScopes { get; private set; }
public IReadOnlyList<string> AcceptedOauthScopes { get; private set; }
/// <summary>
/// Etag
+1 -1
View File
@@ -17,7 +17,7 @@ namespace Octokit.Http
Task<T> Get(Uri endpoint, IDictionary<string, string> parameters);
Task<TOther> GetItem<TOther>(Uri endpoint, IDictionary<string, string> parameters);
Task<string> GetHtml(Uri endpoint, IDictionary<string, string> parameters);
Task<IReadOnlyCollection<T>> GetAll(Uri endpoint, IDictionary<string, string> parameters);
Task<IReadOnlyList<T>> GetAll(Uri endpoint, IDictionary<string, string> parameters);
Task<T> Create(Uri endpoint, object data);
Task<T> Update(Uri endpoint, object data);
Task Delete(Uri endpoint);
+1 -1
View File
@@ -6,6 +6,6 @@ namespace Octokit
{
public interface IApiPagination<T>
{
Task<IReadOnlyCollection<T>> GetAllPages(Func<Task<IReadOnlyPagedCollection<T>>> getFirstPage);
Task<IReadOnlyList<T>> GetAllPages(Func<Task<IReadOnlyPagedCollection<T>>> getFirstPage);
}
}
+1 -1
View File
@@ -8,7 +8,7 @@ namespace Octokit
{
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "It's an API call, so it's not a property.")]
Task<IReadOnlyCollection<Authorization>> GetAll();
Task<IReadOnlyList<Authorization>> GetAll();
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
Justification = "It's fiiiine. It's fine. Trust us.")]
Task<Authorization> Get(int id);
+2 -2
View File
@@ -21,13 +21,13 @@ namespace Octokit
/// <returns></returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Method makes a network request")]
Task<IReadOnlyCollection<Organization>> GetAllForCurrent();
Task<IReadOnlyList<Organization>> GetAllForCurrent();
/// <summary>
/// Returns all the organizations for the specified user
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
Task<IReadOnlyCollection<Organization>> GetAll(string user);
Task<IReadOnlyList<Organization>> GetAll(string user);
}
}
+2 -2
View File
@@ -5,10 +5,10 @@ using System.Threading.Tasks;
namespace Octokit
{
/// <summary>
/// Reflects a collection of datat returned from an API that can be paged.
/// Reflects a collection of data returned from an API that can be paged.
/// </summary>
/// <typeparam name="T"></typeparam>
public interface IReadOnlyPagedCollection<T> : IReadOnlyCollection<T>
public interface IReadOnlyPagedCollection<T> : IReadOnlyList<T>
{
/// <summary>
/// Returns the next page of items.
+1 -1
View File
@@ -11,7 +11,7 @@ namespace Octokit
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <returns>A <see cref="IReadonlyPagedCollection{Release}"/> of <see cref="Release"/>.</returns>
Task<IReadOnlyCollection<Release>> GetAll(string owner, string name);
Task<IReadOnlyList<Release>> GetAll(string owner, string name);
/// <summary>
/// Create a <see cref="Release"/> for the specified repository.
+3 -3
View File
@@ -26,7 +26,7 @@ namespace Octokit
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
Task<IReadOnlyCollection<Repository>> GetAllForCurrent();
Task<IReadOnlyList<Repository>> GetAllForCurrent();
/// <summary>
/// Retrieves every <see cref="Repository"/> that belongs to the specified user.
@@ -37,7 +37,7 @@ namespace Octokit
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
Task<IReadOnlyCollection<Repository>> GetAllForUser(string login);
Task<IReadOnlyList<Repository>> GetAllForUser(string login);
/// <summary>
/// Retrieves every <see cref="Repository"/> that belongs to the specified organization.
@@ -48,7 +48,7 @@ namespace Octokit
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
Task<IReadOnlyCollection<Repository>> GetAllForOrg(string organization);
Task<IReadOnlyList<Repository>> GetAllForOrg(string organization);
/// <summary>
/// Returns the HTML rendered README.
+2 -2
View File
@@ -19,7 +19,7 @@ namespace Octokit
/// </summary>
/// <param name="user">The login of the user.</param>
/// <returns>A <see cref="IReadOnlyPagedCollection{SshKey}"/> of <see cref="SshKey"/>.</returns>
Task<IReadOnlyCollection<SshKey>> GetAll(string user);
Task<IReadOnlyList<SshKey>> GetAll(string user);
/// <summary>
/// Retrieves the <see cref="SshKey"/> for the specified id.
@@ -28,7 +28,7 @@ namespace Octokit
/// <returns>A <see cref="IReadOnlyPagedCollection{SshKey}"/> of <see cref="SshKey"/>.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
Task<IReadOnlyCollection<SshKey>> GetAllForCurrent();
Task<IReadOnlyList<SshKey>> GetAllForCurrent();
/// <summary>
/// Update the specified <see cref="UserUpdate"/>.
+2 -2
View File
@@ -18,7 +18,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL</DefineConstants>
<DefineConstants>TRACE;DEBUG;CODE_ANALYSIS;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>true</RunCodeAnalysis>
@@ -31,7 +31,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;CODE_ANALYSIS;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
+1 -1
View File
@@ -28,7 +28,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\WinRT\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL</DefineConstants>
<DefineConstants>TRACE;NETFX_CORE;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>