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

Add Response abstraction #3693

Closed
m-nash opened this issue Jun 28, 2024 · 1 comment · Fixed by #4438
Closed

Add Response abstraction #3693

m-nash opened this issue Jun 28, 2024 · 1 comment · Fixed by #4438
Assignees
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Comments

@m-nash
Copy link
Member

m-nash commented Jun 28, 2024

We will need an abstraction for a response from a client service call in order to be able to replace this via plugins.

Methods that need to be provided include (not exhaustive)

  • Type
  • GetRawResponse
  • IsError
  • Buffering
  • Failure exception
  • derived types such as
    • ErrorResponse
    • NullableResponse
@m-nash m-nash added emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp and removed needs-area labels Jun 28, 2024
@live1206 live1206 self-assigned this Sep 9, 2024
@ArcturusZhang
Copy link
Member

ArcturusZhang commented Sep 12, 2024

So I think maybe this could something like:

public abstract class ClientResponse
{
	public CSharpType Type {get;}
	public CSharpType ExceptionType {get;}
	public CSharpType ErrorVariantType {get;}
	public CSharpType NullableVariantType {get;}
}

public static class ClientResponseSnippets
{
	public ValueExpression GetRawResponse(this ScopeApi<ClientResponse> response) {}
	// etc
}

so that we separate this thing into two parts: data (containing the types we use), and actions (containing the methods/properties we could call)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants