Skip to content

SCM: Remove PageCollection types in favor of using CollectionResult#45961

Merged
annelo-msft merged 27 commits into
Azure:mainfrom
annelo-msft:scm-protocol-collection
Sep 17, 2024
Merged

SCM: Remove PageCollection types in favor of using CollectionResult#45961
annelo-msft merged 27 commits into
Azure:mainfrom
annelo-msft:scm-protocol-collection

Conversation

@annelo-msft
Copy link
Copy Markdown
Contributor

@annelo-msft annelo-msft commented Sep 13, 2024

Background

Given feedback from partners that SCM PageCollection<T> and related types were too complex for the convenience layer, we have reworked the client patterns to simplify usage for the simplest use case of paginated service methods -- i.e. the return type now implements IEnumerable<T>, which means that strongly typed models in a paginated collection can now be enumerated directly. This better aligns the SCM client pattern for pagination with the Azure client pattern as well. One side effect of this is that the implementation of a complex scenario like rehydrating a collection becomes more complex, but this seems like a good tradeoff.

What's in this PR?

  • This PR removes PageCollection<T> and related types in favor of new APIs on CollectionResult<T> and AsyncCollectionResult<T>
  • It adds two new protocol-method return types CollectionResult and AsyncCollectionResult that the convenience-layer return types now inherit from
  • CollectionResult<T> no longer inherits from ClientResult, but instead enables access to the sequence of service responses that deliver the collection items via a new GetRawPages method on the CollectionResult base type
  • Since it is preferrable that ClientResult represents a single HTTP response, this PR removes its parameterless constructor and moves its SetRawResponse method onto OperationResult, which is the only type that now needs it to update the value returned from GetRawResponse
  • Given the changes to the design of the collection result types, tests have been restructured and simplified, and reference implementations provided to show how clients might implement internal subtypes of CollectionResult and related types for both paginated service endpoints and streaming responses.

@azure-sdk
Copy link
Copy Markdown
Collaborator

azure-sdk commented Sep 13, 2024

API change check

APIView has identified API level changes in this PR and created following API reviews.

System.ClientModel

Comment thread sdk/core/System.ClientModel/src/Convenience/AsyncCollectionResult.cs Outdated
Comment thread sdk/core/System.ClientModel/src/Convenience/PageResultOfT.cs Outdated
Comment thread sdk/core/System.ClientModel/tests/client/TestClients/PagingClient/PagingClient.cs Outdated
Comment thread sdk/core/System.ClientModel/src/Convenience/ClientResult.cs Outdated
@annelo-msft annelo-msft changed the title Experiment: SCM Protocol CollectionResult SCM: Remove PageCollection types in favor of using CollectionResult Sep 16, 2024
@annelo-msft annelo-msft marked this pull request as ready for review September 16, 2024 17:47
@annelo-msft annelo-msft requested a review from a team as a code owner September 16, 2024 17:47
Comment thread sdk/core/System.ClientModel/src/Convenience/AsyncCollectionResultOfT.cs Outdated
Comment thread sdk/core/System.ClientModel/src/Convenience/CollectionResult.cs Outdated
Comment thread sdk/core/System.ClientModel/src/Convenience/OperationResult.cs Outdated
@annelo-msft
Copy link
Copy Markdown
Contributor Author

/azp run net - openai - ci

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants