Fix C# ClientResult conversions for streaming events - #11858
Open
JoshLove-msft wants to merge 1 commit into
Open
Fix C# ClientResult conversions for streaming events#11858JoshLove-msft wants to merge 1 commit into
JoshLove-msft wants to merge 1 commit into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
JoshLove-msft
requested review from
Jorge Rangel (jorgerangel-msft),
Jose Arriaga Maldonado (joseharriaga),
Jesse Squire (jsquire) and
m-nash
as code owners
September 4, 2026 00:26
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The core logic change aligns with the reported bug and is covered by a targeted regression test; remaining feedback is a non-blocking test-assertion precision improvement.
Pull request overview
This PR adjusts the C# http-client generator’s “root output model” detection so streaming payload/event models are no longer treated as ClientResult-castable outputs, preventing generation of unusable public static explicit operator <Model>(ClientResult) API surface for SSE/JSON Lines streaming scenarios (fix for #11856).
Changes:
- Stop considering
InputStreamingType.ValueTypeas a rootClientResultoutput model (so streaming item/event models don’t getClientResultconversion operators). - Add regression coverage ensuring streaming responses do not produce
ClientResultexplicit operators. - Regenerate Spector and local streaming fixtures to reflect the removed operator(s).
File summaries
| File | Description |
|---|---|
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/ScmTypeFactory.cs | Removes streaming-type recursion when collecting RootOutputModels, preventing generation of ClientResult conversion operators for streaming payload models. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/MrwSerializationTypeDefinitions/DynamicModelSerializationTests.cs | Adds a regression test for SSE/JSONL streaming responses to ensure no explicit ClientResult operator is generated. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/Models/Info.Serialization.cs | Regenerated fixture: removes ClientResult explicit operator for SSE streaming model. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/jsonl/src/Generated/Models/Info.Serialization.cs | Regenerated fixture: removes ClientResult explicit operator for JSONL streaming model. |
| packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/StreamingItem.Serialization.cs | Regenerated fixture: removes ClientResult explicit operator for a streaming payload model. |
Review details
- Files reviewed: 2/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+1306
to
+1310
| Assert.That( | ||
| serialization!.Methods.Any(m => | ||
| m.Signature.Modifiers.HasFlag(MethodSignatureModifiers.Explicit) && | ||
| m.Signature.Modifiers.HasFlag(MethodSignatureModifiers.Operator)), | ||
| Is.False); |
commit: |
Contributor
|
No changes needing a change description found. |
Jonathan Cárdenas (JonathanCrd)
approved these changes
Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Streaming event models are never returned as plain
ClientResultvalues, so generating explicit conversions for them adds unusable API surface.Summary
ClientResultoutputs.Testing
npm run buildnpm run test:generatornpm run test:emitternpm run formatoxlintnpm run copFixes: #11856