Skip to content

[http-client-csharp] Adopt streaming/jsonl Spector scenario#10754

Draft
JonathanCrd wants to merge 4 commits into
microsoft:mainfrom
JonathanCrd:joncarde/spector-streaming-jsonl-adoption
Draft

[http-client-csharp] Adopt streaming/jsonl Spector scenario#10754
JonathanCrd wants to merge 4 commits into
microsoft:mainfrom
JonathanCrd:joncarde/spector-streaming-jsonl-adoption

Conversation

@JonathanCrd
Copy link
Copy Markdown
Member

@JonathanCrd JonathanCrd commented May 21, 2026

Note

Work in Progress — This PR is pending design discussion on how the C# generator should handle streaming operations.

Summary

Adopts the streaming/jsonl Spector scenario for the C# HTTP client emitter.

Tracking issue: #10738

What's Included

  • Spector test wiring: Removed streaming/jsonl from \\ in Spector-Helper.psm1, added project references and launch profile
  • Generated code: Stubbed client, models, and serialization for the JSONL scenario
  • IAsyncEnumerable<T> receive pattern: The BasicReceive test demonstrates streaming-friendly consumption of JSONL responses — reading the response ContentStream line-by-line and yielding deserialized Info objects via IAsyncEnumerable<T>, without buffering the entire payload into memory
  • BasicSend test: Builds the JSONL payload from typed objects and sends via the generated convenience method

Design Gap

The generator currently emits BinaryData for JSONL bodies because TCGC classifies these operations as basic (no streaming method kind exists). The IAsyncEnumerable<T> pattern is demonstrated in the test code as a proof-of-concept for what the generator should eventually emit automatically.

See review discussion in PR #10740 for context on the streaming design considerations.


🤖 Created with JonathanCrd's copilot

JonathanCrd and others added 3 commits May 19, 2026 15:32
…n MethodParameterSegments navigation

When MethodParameterSegments navigation resolves to a BinaryData property,
the expression was passed directly as a BinaryContent protocol argument
without wrapping. This caused a CS1503 compilation error.

Wrap the resolved property expression with RequestContentApiSnippets.Create()
when the protocol parameter is a content parameter.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ntent fix

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove streaming/jsonl from failingSpecs list
- Add generated stub project under Spector/http/streaming/jsonl/
- Add JsonlTests.cs with BasicSend and BasicReceive tests
- Add project reference in Spector.Tests.csproj
- Update launchSettings.json via full Generate.ps1

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label May 21, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 21, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@10754

commit: 7fcaebb

@github-actions
Copy link
Copy Markdown
Contributor

No changes needing a change description found.

… test

Update BasicReceive test to use the protocol method and enumerate the
response stream line-by-line via IAsyncEnumerable<Info>, demonstrating
the streaming-friendly pattern that avoids buffering the entire JSONL
payload into memory.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 this pull request may close these issues.

1 participant