Skip to content

Fix C# discriminator forwarding when base constructor parameters are empty - #12075

Draft
JoshLove-msft with Copilot wants to merge 2 commits into
mainfrom
copilot/http-client-csharp-fix-discriminator-omission
Draft

JoshLove-msft with Copilot wants to merge 2 commits into
mainfrom
copilot/http-client-csharp-fix-discriminator-omission

Conversation

Copilot AI commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

With hierarchyBuilding, a derived constructor could implicitly call the intermediate base’s parameterless constructor, initializing the wrong discriminator and producing incorrect serialized output.

  • Constructor initialization: Evaluate multi-level discriminator forwarding before checking for ordinary base parameters. Preserve the existing fallback paths.
  • Regression coverage: Extend the three-level hierarchy test to cover optional-only base properties alongside required properties.

The derived constructor now explicitly passes its discriminator:

public CosmosSqlDataTransferDataSourceSink(
    string databaseName,
    string containerName)
    : base("CosmosDBSql")
{
    DatabaseName = databaseName;
    ContainerName = containerName;
}

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

…parameters

Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Sep 29, 2026
Copilot AI changed the title [WIP] Fix derived constructor discriminator omission in hierarchyBuilding Fix C# discriminator forwarding when base constructor parameters are empty Sep 29, 2026
Copilot AI requested a review from JoshLove-msft September 29, 2026 22:06

This branch has not been deployed

No deployments
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.

[http-client-csharp] hierarchyBuilding derived constructor omits discriminator when base has no required parameters

2 participants