Repository navigation
[http-client-csharp] Emit LRO status metadata - #12628
Open
iscai-msft wants to merge 1 commit into
Open
iscai-msft wants to merge 1 commit into
iscai-msft wants to merge 1 commit into
Conversation
Emit @lroStatusMetadata selections as references to the polling response model's own properties, and ensure the polling model graph is generated with JSON deserialization so consumers can reuse its generated deserializer.
iscai-msft
requested review from
JoshLove01,
Alan Zimmer (alzimmermsft),
Jorge Rangel (jorgerangel-msft),
Jose Arriaga Maldonado (joseharriaga) and
m-nash
as code owners
November 20, 2026 18:10
commit: |
Contributor
|
No changes needing a change description found. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Hidden monitors can leave cached input-only base models missing Output | Json usage, and required-field validation failures lack negative test coverage.
2 open issues
What changed in this PR
Adds LRO status metadata to the C# emitter’s shared input contract for downstream generators, preserving references to polling models and their properties.
Changes:
- Emits polling-response models and ordered status selections, promoting model graphs to JSON output usage.
- Adds C# input types and deserialization support while preserving existing constructors and skipping unknown metadata fields.
- Adds emitter and C# tests with a shared, synchronization-checked JSON fixture.
| File | Description |
|---|---|
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.Input/test/TestData/InputServiceMethodTests/LoadsEmittedLroStatusMetadata/tspCodeModel.json |
Shared emitted metadata fixture. |
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.Input/test/InputServiceMethodTests.cs |
Tests references, legacy input, and unknown fields. |
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.Input/src/InputTypes/Serialization/TypeSpecSerialization.cs |
Registers the status metadata converter. |
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.Input/src/InputTypes/Serialization/InputLroStatusMetadataConverter.cs |
Deserializes selections and required property paths. |
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.Input/src/InputTypes/Serialization/InputLongRunningServiceMetadataConverter.cs |
Reads new fields and skips unknown properties. |
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.Input/src/InputTypes/InputLroStatusMetadata.cs |
Defines the C# status-selection contract. |
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.Input/src/InputTypes/InputLongRunningServiceMetadata.cs |
Adds polling model and selection properties. |
packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts |
Tests selection identity, usage, omission, and fixture synchronization. |
packages/http-client-csharp/emitter/src/type/input-service-method.ts |
Defines TypeScript status metadata contracts. |
packages/http-client-csharp/emitter/src/lib/operation-converter.ts |
Converts selections and promotes polling graph usage. |
Review effort: Balanced
Comment on lines
+749
to
+754
| for (const type of outputTypes) { | ||
| const inputType = sdkContext.__typeCache.types.get(type); | ||
| if (inputType?.kind === "model" || inputType?.kind === "enum") { | ||
| inputType.usage |= UsageFlags.Output | UsageFlags.Json; | ||
| } | ||
| } |
Comment on lines
+31
to
+33
| return new InputLroStatusMetadata( | ||
| property ?? throw new JsonException("LRO status metadata must have a property."), | ||
| propertySegments ?? throw new JsonException("LRO status metadata must have property segments.")); |
Draft
5 of 9 tasks
This branch has not been deployed
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.


Splits the status-metadata part out of #12563. That PR keeps
@lroOperationIdonly.What
When an LRO method has
@lroStatusMetadataselections (TCGClroMetadata.statusMetadata), the emitter adds two fields tolroMetadata:pollingResponseModel: a$refto the status-monitor response model, converted through the normalfromSdkTypepath.statusMetadata[]:{ property, propertySegments }. Each entry is a$refto the polling model's own cachedInputModelProperty(or a base model's property), not a copy.The polling model graph (including nested models and enums) gets
Output | Jsonusage. It is therefore always generated with its JSON deserializer, even when the status monitor operation is hidden (for example@scope("!csharp")). Consumers read metadata by deserializing the latest polling response once with the generatedDeserialize{Model}, then returning that model's properties.On the C# side,
InputLongRunningServiceMetadatagainsPollingResponseModelandStatusMetadata(IReadOnlyList<InputLroStatusMetadata>), along with a new ctor overload; the existing 3-arg ctor is unchanged.InputLongRunningServiceMetadataConverternow skips unknown properties instead of looping forever.No generated output changes for the unbranded generator. The new public type, properties, and ctor are Input contract API for downstream generators, and the Azure generator owns the operation subclass that consumes them.
Review feedback from #12563
[CodeGenType]).ModelReaderWriterContextDefinitionchange, because there is no new metadata wrapper type.PropertyProvideroverload.main.tspin TestData; the fixture JSON is generated from emitter output, and an emitter test asserts it stays in sync.Known limitation
If the polling response model uses
@alternateType, the original model is still converted when status metadata is present.Tests
LRO status metadatatests cover property references and ordering, usage on a hidden monitor, no fields when nothing is selected, and fixture sync.Microsoft.TypeSpec.Generator.Input.Tests: 337 passed, including new deserialization and unknown-property tests.Microsoft.TypeSpec.Generator.ClientModel.Tests: 2820 passed.