Skip to content

[.NET] Consume TCGC LRO status metadata and operation ID (shared input model) - #12564

Closed
iscai-msft wants to merge 1 commit into
microsoft:mainfrom
iscai-msft:dotnet-shared-lro-metadata-27f
Closed

iscai-msft wants to merge 1 commit into
microsoft:mainfrom
iscai-msft:dotnet-shared-lro-metadata-27f

Conversation

@iscai-msft

Copy link
Copy Markdown
Member

Part of Azure/typespec-azure#5996

Consumes the TCGC 0.74.0 LRO metadata in the shared @typespec/http-client-csharp emitter and input model:

Changes

  • Emitter serializes statusMetadata and operationId on the LRO service metadata, with model properties emitted as input-type references.
  • New C# input types: InputLroStatusMetadata, InputLroOperationIdMetadata (InputLroOperationIdPathMetadata / InputLroOperationIdPropertyMetadata), and InputOperationLink, plus JSON converters. InputLongRunningServiceMetadata gains StatusMetadata and OperationId.
  • When the metadata is absent, behavior and generated output are unchanged (regeneration produces no diffs).

The Azure generator PR in Azure/azure-sdk-for-net (eng/packages/http-client-csharp) consumes this shared model to generate the poller accessors and carries the customization table.

Tests

  • Emitter unit tests for status metadata and operation ID serialization.
  • TypeSpecInputConverterTests coverage for the new converters.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 17:38
@microsoft-github-policy-service microsoft-github-policy-service Bot added emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp labels Nov 12, 2026
@iscai-msft

Copy link
Copy Markdown
Member Author

Closing as a duplicate of #12563.

@iscai-msft iscai-msft closed this Nov 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The empty-segments regression test throws on a missing property before reaching segments validation, leaving the intended validation untested.

1 open issue
What changed in this PR

This PR carries TCGC long-running operation metadata through the shared C# emitter and input model, enabling the Azure generator to consume status values and operation IDs.

Changes:

  • Preserves selected status properties, typed property paths, and ordered operation ID sources.
  • Adds C# input types and JSON converters while retaining defaults when metadata is absent.
  • Adds emitter serialization tests, converter tests, and an internal changelog entry.
File Description
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.Input/​test/​TypeSpecInputConverterTests.cs Tests metadata deserialization and invalid operation IDs.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​Serialization/​TypeSpecSerialization.cs Registers the new converters.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​Serialization/​InputOperationLinkConverter.cs Deserializes operation links.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​Serialization/​InputLroStatusMetadataConverter.cs Deserializes selected status properties and paths.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​Serialization/​InputLroOperationIdMetadataConverter.cs Deserializes path-based and property-based operation IDs.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​Serialization/​InputLongRunningServiceMetadataConverter.cs Reads the new metadata collections and skips unknown fields.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​InputOperationLink.cs Represents an operation link’s location and property.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​InputLroStatusMetadata.cs Represents selected status values and typed paths.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​InputLroOperationIdPropertyMetadata.cs Represents property-based operation IDs.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​InputLroOperationIdPathMetadata.cs Represents operation IDs extracted using polling routes.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​InputLroOperationIdMetadata.cs Adds the shared operation ID metadata base type.
packages/​http-client-csharp/​generator/​Microsoft.TypeSpec.Generator.Input/​src/​InputTypes/​InputLongRunningServiceMetadata.cs Exposes metadata collections with backward-compatible constructors.
packages/​http-client-csharp/​emitter/​test/​Unit/​operation-converter.test.ts Tests metadata preservation and serialized references.
packages/​http-client-csharp/​emitter/​src/​type/​input-service-method.ts Defines the emitter’s metadata shapes.
packages/​http-client-csharp/​emitter/​src/​lib/​type-converter.ts Exposes property conversion for metadata references.
packages/​http-client-csharp/​emitter/​src/​lib/​operation-converter.ts Maps TCGC metadata into the shared input model.
.chronus/​changes/​dotnet-shared-lro-metadata-2026-11-12.md Records the shared-model enhancement.

Review effort: Balanced

Comment on lines +98 to +105
[TestCase("""{"kind":"property","propertySegments":[]}""")]
[TestCase("""{"kind":"path","path":"/jobs/{id}"}""")]
public void RejectsInvalidLongRunningOperationId(string json)
{
var options = new JsonSerializerOptions
{
Converters = { new InputLroOperationIdMetadataConverter() }
};
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.

2 participants