Skip to content

[http-client-csharp] Avoid retaining unused PipelineRequestHeadersExtensions for Azure request APIsย #11291

Description

@live1206

Description

The provider reference map retains PipelineRequestHeadersExtensions for Azure data-plane clients with prefixed dictionary headers even when the emitted request API is Azure.Core and never uses PipelineRequestHeaders.

Observed during full Azure SDK data-plane regeneration for PR #11288. The following new internal files are generated:

  • sdk/storage/Azure.Storage.Files.Shares/src/Generated/Internal/PipelineRequestHeadersExtensions.cs
  • sdk/storage/Azure.Storage.Queues/src/Generated/Internal/PipelineRequestHeadersExtensions.cs

Both helpers are internal and do not affect public API. The Storage projects build successfully when the files are removed.

Root cause

RestClientProvider.BuildHelperDependencyTypes hard-codes PipelineRequestHeadersExtensionsDefinition whenever an operation has a dictionary header with CollectionHeaderPrefix.

That dependency is correct for the default System.ClientModel PipelineRequestProvider, but not for Azure's request abstraction. The emitted Storage code uses Azure.Core RequestHeaders.Add(prefix, dictionary) instead, so the generated PipelineRequestHeaders helper is unused. The former Roslyn reference map pruned the unused type from the final compilation; the provider graph treats the hard-coded helper dependency as authoritative and retains it.

Proposed fix

Express the required collection-header helper as a capability/dependency of HttpRequestApi (or the selected request API implementation), rather than hard-coding the System.ClientModel helper in RestClientProvider.

  • The default PipelineRequestProvider should report PipelineRequestHeadersExtensionsDefinition.
  • Azure's request API should report no generated helper because Azure.Core supplies the applicable operation.
  • Add coverage proving prefixed dictionary headers retain the helper only for request APIs that require it.

Validation

A targeted local regeneration of Azure.Storage.Files.Shares and Azure.Storage.Queues reproduces both new files. Both SDKs regenerate and build successfully, and Azure.Storage.Queues also builds successfully after removing the generated helper.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingemitter:client:csharpIssue for the C# client emitter: @typespec/http-client-csharp

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions