fix(http-client-csharp): include protocol-only paging response model in code model#10422
Open
JoshLove-msft wants to merge 3 commits intomicrosoft:mainfrom
Open
fix(http-client-csharp): include protocol-only paging response model in code model#10422JoshLove-msft wants to merge 3 commits intomicrosoft:mainfrom
JoshLove-msft wants to merge 3 commits intomicrosoft:mainfrom
Conversation
…in code model When a paging operation is annotated with @convenientAPI(false), TCGC does not include the anonymous response model (the model containing the @nextlink or @continuationToken property) in sdkPackage.models. The C# emitter previously snapshotted __typeCache.types BEFORE processing clients, so any models reachable only via operations were excluded from the code model. The generator's CollectionResultDefinition then emitted code that referenced a non-existent model class. Take the snapshot AFTER fromSdkClients runs so types added during operation/response processing are captured. Fixes microsoft#9391 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
commit: |
Contributor
|
No changes needing a change description found. |
Collaborator
|
You can try these changes here
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Fixes #9391
When a paging operation is annotated with @convenientAPI(false), TCGC does not include the anonymous response model (the model containing the @nextLink/@continuationToken property) in sdkPackage.models. The C# emitter previously snapshotted
__typeCache.typesBEFORE processing clients, so models reachable only via operations were excluded from the code model. The generator'sCollectionResultDefinitionthen emitted code that cast the raw response to a non-existent model class (e.g.,((MyOpResponse)result).Next), producing a CS0234 build error.Fix
In
client-model-builder.ts, take the models/enums snapshot from__typeCache.typesAFTERfromSdkClientsruns, so any types that were only visited during operation/response processing are captured. (constantswas already snapshotted afterfromSdkClients— this aligns models/enums with that pattern.)Test
Added a unit test in
operation-paging.test.tsthat asserts the anonymous response model for a@convenientAPI(false)paging op is present in the code model.Manually reproduced by adding such an op to
Sample-TypeSpec— without the fix,dotnet buildfails with CS0234; with the fix it succeeds.