Skip to content

Commit df009e0

Browse files
committed
Remove Task/Func paging methods, c# types are too strict for that
1 parent de98bc0 commit df009e0

File tree

3 files changed

+1
-276
lines changed

3 files changed

+1
-276
lines changed

SpotifyAPI.Web.Examples/Example.CLI.PersistentConfig/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private static async Task Start()
5959
var me = await spotify.UserProfile.Current();
6060
Console.WriteLine($"Welcome {me.DisplayName} ({me.Id}), your authenticated!");
6161

62-
var playlists = await spotify.PaginateAll(spotify.Playlists.CurrentUsers());
62+
var playlists = await spotify.PaginateAll(await spotify.Playlists.CurrentUsers().ConfigureAwait(false));
6363
Console.WriteLine($"Total Playlists in your Account: {playlists.Count}");
6464

6565
_server.Dispose();

SpotifyAPI.Web/Clients/Interfaces/ISpotifyClient.cs

Lines changed: 0 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -109,28 +109,6 @@ public interface ISpotifyClient
109109
/// <returns>A list containing all fetched pages</returns>
110110
Task<IList<T>> PaginateAll<T>(IPaginatable<T> firstPage, IPaginator? paginator = default!);
111111

112-
/// <summary>
113-
/// Fetches all pages and returns them grouped in a list.
114-
/// The default paginator will fetch all available resources without a delay between requests.
115-
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
116-
/// </summary>
117-
/// <param name="getFirstPage">A function to retrive the first page, will be included in the output list!</param>
118-
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
119-
/// <typeparam name="T">The Paging-Type</typeparam>
120-
/// <returns>A list containing all fetched pages</returns>
121-
Task<IList<T>> PaginateAll<T>(Func<Task<IPaginatable<T>>> getFirstPage, IPaginator? paginator = default!);
122-
123-
/// <summary>
124-
/// Fetches all pages and returns them grouped in a list.
125-
/// The default paginator will fetch all available resources without a delay between requests.
126-
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
127-
/// </summary>
128-
/// <param name="firstPageTask">A task to retrive the first page, will be included in the output list!</param>
129-
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
130-
/// <typeparam name="T">The Paging-Type</typeparam>
131-
/// <returns>A list containing all fetched pages</returns>
132-
Task<IList<T>> PaginateAll<T>(Task<IPaginatable<T>> firstPageTask, IPaginator? paginator = default!);
133-
134112
/// <summary>
135113
/// Fetches all pages and returns them grouped in a list.
136114
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
@@ -150,44 +128,6 @@ Task<IList<T>> PaginateAll<T, TNext>(
150128
IPaginator? paginator = default!
151129
);
152130

153-
/// <summary>
154-
/// Fetches all pages and returns them grouped in a list.
155-
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
156-
/// To workaround this limitation, the mapper is required and needs to point to the correct next pagination.
157-
/// The default paginator will fetch all available resources without a delay between requests.
158-
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
159-
/// </summary>
160-
/// <param name="getFirstPage">A function to retrive the first page, will be included in the output list!</param>
161-
/// <param name="mapper">A function which maps response objects to the next paging object</param>
162-
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
163-
/// <typeparam name="T">The Paging-Type</typeparam>
164-
/// <typeparam name="TNext">The Response-Type</typeparam>
165-
/// <returns></returns>
166-
Task<IList<T>> PaginateAll<T, TNext>(
167-
Func<Task<IPaginatable<T, TNext>>> getFirstPage,
168-
Func<TNext, IPaginatable<T, TNext>> mapper,
169-
IPaginator? paginator = default!
170-
);
171-
172-
/// <summary>
173-
/// Fetches all pages and returns them grouped in a list.
174-
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
175-
/// To workaround this limitation, the mapper is required and needs to point to the correct next pagination.
176-
/// The default paginator will fetch all available resources without a delay between requests.
177-
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
178-
/// </summary>
179-
/// <param name="firstPageTask">A Task to retrive the first page, will be included in the output list!</param>
180-
/// <param name="mapper">A function which maps response objects to the next paging object</param>
181-
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
182-
/// <typeparam name="T">The Paging-Type</typeparam>
183-
/// <typeparam name="TNext">The Response-Type</typeparam>
184-
/// <returns></returns>
185-
Task<IList<T>> PaginateAll<T, TNext>(
186-
Task<IPaginatable<T, TNext>> firstPageTask,
187-
Func<TNext, IPaginatable<T, TNext>> mapper,
188-
IPaginator? paginator = default!
189-
);
190-
191131
#if NETSTANDARD2_1
192132
/// <summary>
193133
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
@@ -205,38 +145,6 @@ IAsyncEnumerable<T> Paginate<T>(
205145
CancellationToken cancellationToken = default!
206146
);
207147

208-
/// <summary>
209-
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
210-
/// The default paginator will fetch all available resources without a delay between requests.
211-
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
212-
/// </summary>
213-
/// <param name="getFirstPage">A Function to retrive the first page, will be included in the output list!</param>
214-
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
215-
/// <param name="cancellationToken">An optional Cancellation Token</param>
216-
/// <typeparam name="T">The Paging-Type</typeparam>
217-
/// <returns>An iterable IAsyncEnumerable</returns>
218-
IAsyncEnumerable<T> Paginate<T>(
219-
Func<Task<IPaginatable<T>>> getFirstPage,
220-
IPaginator? paginator = default!,
221-
CancellationToken cancellationToken = default!
222-
);
223-
224-
/// <summary>
225-
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
226-
/// The default paginator will fetch all available resources without a delay between requests.
227-
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
228-
/// </summary>
229-
/// <param name="firstPageTask">A Task to retrive the first page, will be included in the output list!</param>
230-
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
231-
/// <param name="cancellationToken">An optional Cancellation Token</param>
232-
/// <typeparam name="T">The Paging-Type</typeparam>
233-
/// <returns>An iterable IAsyncEnumerable</returns>
234-
IAsyncEnumerable<T> Paginate<T>(
235-
Task<IPaginatable<T>> firstPageTask,
236-
IPaginator? paginator = default!,
237-
CancellationToken cancellationToken = default!
238-
);
239-
240148
/// <summary>
241149
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
242150
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
@@ -258,47 +166,6 @@ IAsyncEnumerable<T> Paginate<T, TNext>(
258166
CancellationToken cancellationToken = default!
259167
);
260168

261-
/// <summary>
262-
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
263-
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
264-
/// To workaround this limitation, the mapper is required and needs to point to the correct next pagination.
265-
/// The default paginator will fetch all available resources without a delay between requests.
266-
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
267-
/// </summary>
268-
/// <param name="getFirstPage">A Function to retrive the first page, will be included in the output list!</param>
269-
/// <param name="mapper">A function which maps response objects to the next paging object</param>
270-
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
271-
/// <param name="cancellationToken">An optional Cancellation Token</param>
272-
/// <typeparam name="T">The Paging-Type</typeparam>
273-
/// <typeparam name="TNext">The Response-Type</typeparam>
274-
/// <returns></returns>
275-
IAsyncEnumerable<T> Paginate<T, TNext>(
276-
Func<Task<IPaginatable<T, TNext>>> getFirstPage,
277-
Func<TNext, IPaginatable<T, TNext>> mapper,
278-
IPaginator? paginator = default!,
279-
CancellationToken cancellationToken = default!
280-
);
281-
282-
/// <summary>
283-
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
284-
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
285-
/// To workaround this limitation, the mapper is required and needs to point to the correct next pagination.
286-
/// The default paginator will fetch all available resources without a delay between requests.
287-
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
288-
/// </summary>
289-
/// <param name="firstPageTask">A Task to retrive the first page, will be included in the output list!</param>
290-
/// <param name="mapper">A function which maps response objects to the next paging object</param>
291-
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
292-
/// <param name="cancellationToken">An optional Cancellation Token</param>
293-
/// <typeparam name="T">The Paging-Type</typeparam>
294-
/// <typeparam name="TNext">The Response-Type</typeparam>
295-
/// <returns></returns>
296-
IAsyncEnumerable<T> Paginate<T, TNext>(
297-
Task<IPaginatable<T, TNext>> firstPageTask,
298-
Func<TNext, IPaginatable<T, TNext>> mapper,
299-
IPaginator? paginator = default!,
300-
CancellationToken cancellationToken = default!
301-
);
302169
#endif
303170
}
304171
}

SpotifyAPI.Web/Clients/SpotifyClient.cs

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -96,41 +96,6 @@ public Task<IList<T>> PaginateAll<T>(IPaginatable<T> firstPage, IPaginator? pagi
9696
return (paginator ?? DefaultPaginator).PaginateAll(firstPage, _apiConnector);
9797
}
9898

99-
/// <summary>
100-
/// Fetches all pages and returns them grouped in a list.
101-
/// The default paginator will fetch all available resources without a delay between requests.
102-
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
103-
/// </summary>
104-
/// <param name="getFirstPage">A function to retrive the first page, will be included in the output list!</param>
105-
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
106-
/// <typeparam name="T">The Paging-Type</typeparam>
107-
/// <returns>A list containing all fetched pages</returns>
108-
public async Task<IList<T>> PaginateAll<T>(Func<Task<IPaginatable<T>>> getFirstPage, IPaginator? paginator = null)
109-
{
110-
Ensure.ArgumentNotNull(getFirstPage, nameof(getFirstPage));
111-
112-
var firstPage = await getFirstPage().ConfigureAwait(false);
113-
return await (paginator ?? DefaultPaginator).PaginateAll(firstPage, _apiConnector).ConfigureAwait(false);
114-
}
115-
116-
/// <summary>
117-
/// Fetches all pages and returns them grouped in a list.
118-
/// The default paginator will fetch all available resources without a delay between requests.
119-
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
120-
/// </summary>
121-
/// <param name="firstPageTask">A task to retrive the first page, will be included in the output list!</param>
122-
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
123-
/// <typeparam name="T">The Paging-Type</typeparam>
124-
/// <returns>A list containing all fetched pages</returns>
125-
public async Task<IList<T>> PaginateAll<T>(Task<IPaginatable<T>> firstPageTask, IPaginator? paginator = null)
126-
{
127-
Ensure.ArgumentNotNull(firstPageTask, nameof(firstPageTask));
128-
129-
var firstPage = await firstPageTask.ConfigureAwait(false);
130-
return await (paginator ?? DefaultPaginator).PaginateAll(firstPage, _apiConnector).ConfigureAwait(false);
131-
}
132-
133-
13499
/// <summary>
135100
/// Fetches all pages and returns them grouped in a list.
136101
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
@@ -153,57 +118,6 @@ public Task<IList<T>> PaginateAll<T, TNext>(
153118
return (paginator ?? DefaultPaginator).PaginateAll(firstPage, mapper, _apiConnector);
154119
}
155120

156-
157-
/// <summary>
158-
/// Fetches all pages and returns them grouped in a list.
159-
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
160-
/// To workaround this limitation, the mapper is required and needs to point to the correct next pagination.
161-
/// The default paginator will fetch all available resources without a delay between requests.
162-
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
163-
/// </summary>
164-
/// <param name="getFirstPage">A function to retrive the first page, will be included in the output list!</param>
165-
/// <param name="mapper">A function which maps response objects to the next paging object</param>
166-
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
167-
/// <typeparam name="T">The Paging-Type</typeparam>
168-
/// <typeparam name="TNext">The Response-Type</typeparam>
169-
/// <returns></returns>
170-
public async Task<IList<T>> PaginateAll<T, TNext>(
171-
Func<Task<IPaginatable<T, TNext>>> getFirstPage,
172-
Func<TNext, IPaginatable<T, TNext>> mapper,
173-
IPaginator? paginator = null
174-
)
175-
{
176-
Ensure.ArgumentNotNull(getFirstPage, nameof(getFirstPage));
177-
178-
var firstPage = await getFirstPage().ConfigureAwait(false);
179-
return await (paginator ?? DefaultPaginator).PaginateAll(firstPage, mapper, _apiConnector).ConfigureAwait(false);
180-
}
181-
182-
/// <summary>
183-
/// Fetches all pages and returns them grouped in a list.
184-
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
185-
/// To workaround this limitation, the mapper is required and needs to point to the correct next pagination.
186-
/// The default paginator will fetch all available resources without a delay between requests.
187-
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
188-
/// </summary>
189-
/// <param name="firstPageTask">A Task to retrive the first page, will be included in the output list!</param>
190-
/// <param name="mapper">A function which maps response objects to the next paging object</param>
191-
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
192-
/// <typeparam name="T">The Paging-Type</typeparam>
193-
/// <typeparam name="TNext">The Response-Type</typeparam>
194-
/// <returns></returns>
195-
public async Task<IList<T>> PaginateAll<T, TNext>(
196-
Task<IPaginatable<T, TNext>> firstPageTask,
197-
Func<TNext, IPaginatable<T, TNext>> mapper,
198-
IPaginator? paginator = null
199-
)
200-
{
201-
Ensure.ArgumentNotNull(firstPageTask, nameof(firstPageTask));
202-
203-
var firstPage = await firstPageTask.ConfigureAwait(false);
204-
return await (paginator ?? DefaultPaginator).PaginateAll(firstPage, mapper, _apiConnector).ConfigureAwait(false);
205-
}
206-
207121
#if NETSTANDARD2_1
208122

209123
/// <summary>
@@ -225,62 +139,6 @@ public IAsyncEnumerable<T> Paginate<T>(
225139
return (paginator ?? DefaultPaginator).Paginate(firstPage, _apiConnector, cancellationToken);
226140
}
227141

228-
/// <summary>
229-
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
230-
/// The default paginator will fetch all available resources without a delay between requests.
231-
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
232-
/// </summary>
233-
/// <param name="getFirstPage">A Function to retrive the first page, will be included in the output list!</param>
234-
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
235-
/// <param name="cancellationToken">An optional Cancellation Token</param>
236-
/// <typeparam name="T">The Paging-Type</typeparam>
237-
/// <returns>An iterable IAsyncEnumerable</returns>
238-
public async IAsyncEnumerable<T> Paginate<T>(
239-
Func<Task<IPaginatable<T>>> getFirstPage,
240-
IPaginator? paginator = null,
241-
[EnumeratorCancellation] CancellationToken cancellationToken = default
242-
)
243-
{
244-
245-
Ensure.ArgumentNotNull(getFirstPage, nameof(getFirstPage));
246-
247-
var firstPage = await getFirstPage().ConfigureAwait(false);
248-
await foreach (var item in (paginator ?? DefaultPaginator)
249-
.Paginate(firstPage, _apiConnector)
250-
.WithCancellation(cancellationToken)
251-
)
252-
{
253-
yield return item;
254-
}
255-
}
256-
257-
/// <summary>
258-
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
259-
/// The default paginator will fetch all available resources without a delay between requests.
260-
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
261-
/// </summary>
262-
/// <param name="firstPageTask">A Task to retrive the first page, will be included in the output list!</param>
263-
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
264-
/// <param name="cancellationToken">An optional Cancellation Token</param>
265-
/// <typeparam name="T">The Paging-Type</typeparam>
266-
/// <returns>An iterable IAsyncEnumerable</returns>
267-
public async IAsyncEnumerable<T> Paginate<T>(
268-
Task<IPaginatable<T>> firstPageTask,
269-
IPaginator? paginator = null,
270-
[EnumeratorCancellation] CancellationToken cancellationToken = default)
271-
{
272-
Ensure.ArgumentNotNull(firstPageTask, nameof(firstPageTask));
273-
274-
var firstPage = await firstPageTask.ConfigureAwait(false);
275-
await foreach (var item in (paginator ?? DefaultPaginator)
276-
.Paginate(firstPage, _apiConnector)
277-
.WithCancellation(cancellationToken)
278-
)
279-
{
280-
yield return item;
281-
}
282-
}
283-
284142
/// <summary>
285143
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
286144
/// Some responses (e.g search response) have the pagination nested in a JSON Property.

0 commit comments

Comments
 (0)