Skip to content
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

ClientModel: investigation for StreamingClientResult<T> #42873

Closed

Conversation

annelo-msft
Copy link
Member

No description provided.

@@ -92,5 +92,8 @@ public static ClientResult<T> FromValue<T>(T value, PipelineResponse response)
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
Member 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
Member 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
Member 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