Skip to content

ClientModel: investigation for StreamingClientResult<T>#42873

Closed
annelo-msft wants to merge 1 commit intoAzure:mainfrom
annelo-msft:clientmodel-streaming-result
Closed

ClientModel: investigation for StreamingClientResult<T>#42873
annelo-msft wants to merge 1 commit intoAzure:mainfrom
annelo-msft:clientmodel-streaming-result

Conversation

@annelo-msft
Copy link
Copy Markdown
Contributor

No description provided.

public static ClientResult<T?> FromOptionalValue<T>(T? value, PipelineResponse response)
=> new ClientResult<T?>(value, response);

//public static StreamingClientResult<T> FromStreamingValue<T>(T value, PipelineResponse response)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was considering this, but I don't think we can provide it without a non-abstract implementation in ClientModel. It would be the responsibility of the client's concrete subtype to provide such a factory method.

namespace System.ClientModel;

#pragma warning disable CS1591 // public XML comments
public abstract class StreamingClientResult<T> : ClientResult, IAsyncEnumerable<T>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing this does is abstractly implement the IAsyncEnumerable<T> interface, and provide a protected constructor that calls through to the base constructor.

We still have an open question of whether this should implement IDisposable to make it easy to dispose the response content stream by putting this result in a using block, but I'm interested to first investigate how hard it is to use the IAsyncDisposable interface implementation in the IAsyncEnumerator returned from GetAsyncEnumerator.

@annelo-msft
Copy link
Copy Markdown
Contributor Author

Closing in favor of #43392

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.

1 participant