Skip to content

Fix derived model description when no public derived models - #11791

Merged
JoshLove-msft merged 1 commit into
microsoft:mainfrom
BLCCoreStudio:fix-11769-derived-description
Sep 3, 2026
Merged

Fix derived model description when no public derived models#11791
JoshLove-msft merged 1 commit into
microsoft:mainfrom
BLCCoreStudio:fix-11769-derived-description

Conversation

@BLCCoreStudio

Copy link
Copy Markdown
Contributor

Summary

Fixes the C# generator description for discriminated base models whose derived models are all non-public.

ModelProvider.BuildDescription now returns the model description without appending the derived-classes sentence when there are no public derived models. This avoids both the dangling instantiation are: text and its trailing whitespace.

A regression test covers the all-internal-derived-model case.

Fixes #11769

Validation

  • Regression test failed before the fix and passes after it.
  • Microsoft.TypeSpec.Generator.Tests: 2162 passed, 0 failed.
  • npm run build passed.
  • eng/scripts/Generate.ps1 completed successfully.
  • npm run cop passed (cop checks passed.).
  • git diff --check passed.

@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.

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.

Pull request overview

Fixes the C# generator’s model XML doc description for discriminated base models when all derived models are non-public, avoiding a dangling “derived classes available for instantiation are:” sentence (and trailing whitespace).

Changes:

  • Update ModelProvider.BuildDescription to skip appending the derived-classes sentence when there are no public derived models.
  • Add a regression test covering the “all derived models are internal” scenario.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/ModelProvider.cs Skips the derived-classes sentence in the description when publicDerivedModels is empty.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelProviderTests.cs Adds a regression test for discriminated base models with only non-public derived models.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pkg-pr-new

pkg-pr-new Bot commented Sep 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@11791

commit: 14dbe47

@JoshLove-msft
JoshLove-msft added this pull request to the merge queue Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

Merged via the queue into microsoft:main with commit 1ea50a1 Sep 3, 2026
29 checks passed
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.

C# emitter: discriminated base type with no public derived models emits a dangling "instantiation are: " with trailing whitespace

3 participants