-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Experiment for LLC grow-up pageable method #25086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9c72d92
Add tests for grow-up methods for vanilla pageable
annelo-msft b78cc19
Merge remote-tracking branch 'upstream/main' into core-growup-pageable
annelo-msft 2bf7251
make test pass
annelo-msft 5892fc3
work in progress
annelo-msft 32568fc
Merge remote-tracking branch 'upstream/main' into core-growup-pageable
annelo-msft dced0d4
Merge remote-tracking branch 'upstream/main' into core-growup-pageable
annelo-msft dd71c5f
updates
annelo-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
sdk/core/Azure.Core.Experimental/tests/LowLevelClient/PetStoreClient_GrowUpHelpers.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #nullable disable | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Runtime.CompilerServices; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Azure.Core; | ||
| using Azure.Core.Experimental.Tests.Models; | ||
| using Azure.Core.Pipeline; | ||
| using Azure; | ||
| using System.Linq; | ||
|
|
||
| namespace Azure.Core.Experimental.Tests | ||
| { | ||
| /// <summary> The PetStore service client. </summary> | ||
| public partial class PetStoreClient | ||
| { | ||
| public static Pet GetPetFromBinaryData(BinaryData data) | ||
| { | ||
| return data; | ||
| } | ||
|
|
||
| // public virtual AsyncPageable<BinaryData> GetPetsAsync() | ||
| //#pragma warning restore AZC0002 | ||
| // { | ||
| // // TODO: handle need for continuation token and | ||
| // AsyncPageable<BinaryData> pets = GetPetsAsync(new()); | ||
| // pets.AsPages() | ||
|
|
||
| // //return PageableHelpers.create(i => { pets.AsPages}, _clientDiagnostics, "PetStoreClient.GetPets"); | ||
| // //async IAsyncEnumerable<Page<BinaryData>> CreateEnumerableAsync(string nextLink, int? pageSizeHint, [EnumeratorCancellation] CancellationToken cancellationToken = default) | ||
| // //{ | ||
| // // do | ||
| // // { | ||
| // // var message = string.IsNullOrEmpty(nextLink) | ||
| // // ? CreateGetPetsRequest() | ||
| // // : CreateGetPetsNextPageRequest(nextLink); | ||
| // // var page = await LowLevelPageableHelpers.ProcessMessageAsync(Pipeline, message, _clientDiagnostics, options, "value", "nextLink", cancellationToken).ConfigureAwait(false); | ||
| // // nextLink = page.ContinuationToken; | ||
| // // yield return page; | ||
| // // } while (!string.IsNullOrEmpty(nextLink)); | ||
| // //} | ||
| // } | ||
|
|
||
| // TODO: extend to generic | ||
| private class PetPage<Pet> : Page<Pet> | ||
| { | ||
| private Page<BinaryData> _page; | ||
|
|
||
| public PetPage(Page<BinaryData> page) | ||
| { | ||
| _page = page; | ||
| } | ||
|
|
||
| //public override IReadOnlyList<Pet> Values => ()_page.Values.Select(data => GetPetFromBinaryData(data)).ToList().AsReadOnly(); | ||
| //public override IReadOnlyList<Pet> Values => (IReadOnlyList<Pet>)_page.Values.Select(data => GetPetFromBinaryData(data));//.ToList().AsReadOnly(); | ||
| public override IReadOnlyList<Pet> Values => (IReadOnlyList<Pet>)_page.Values.Select(data => | ||
| { | ||
| // Pet pet = (Pet)data; // does not compile | ||
| return GetPetFromBinaryData(data); | ||
| }); | ||
|
|
||
| public override string ContinuationToken => _page.ContinuationToken; | ||
|
|
||
| public override Response GetRawResponse() => _page.GetRawResponse(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the weird part