Skip to content

Preserve internal C# helper types during trimming - #11285

Merged
JoshLove-msft merged 5 commits into
microsoft:mainfrom
JoshLove-msft:joshlove-msft/keep-internal-generated-types
Jul 17, 2026
Merged

Preserve internal C# helper types during trimming#11285
JoshLove-msft merged 5 commits into
microsoft:mainfrom
JoshLove-msft:joshlove-msft/keep-internal-generated-types

Conversation

@JoshLove-msft

@JoshLove-msft JoshLove-msft commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add an InternalHelperProvider base that registers itself with AddTypeToKeep(..., isRoot: false)
  • default helper declarations to internal static, with direct modifier overrides for non-static helpers
  • preserve generic non-root helpers during post-processing and regenerate the local sample

Validation

  • npm run build
  • npm test
  • npm run cop
  • focused helper retention tests
  • formatting completed; emitter lint is currently blocked by the repository's missing ESLint 10 flat config

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
JoshLove-msft and others added 2 commits July 16, 2026 16:43
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@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 Jul 16, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@JoshLove-msft
JoshLove-msft enabled auto-merge July 17, 2026 19:24
@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: e1a7026

@github-actions

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@JoshLove-msft
JoshLove-msft added this pull request to the merge queue Jul 17, 2026
Merged via the queue into microsoft:main with commit 50f7466 Jul 17, 2026
29 checks passed
@JoshLove-msft
JoshLove-msft deleted the joshlove-msft/keep-internal-generated-types branch July 17, 2026 21:09
live1206 added a commit to live1206/typespec that referenced this pull request Jul 20, 2026
Revert the main-branch rollback from microsoft#11282 while preserving the accessibility and SDK-compatibility fixes already on microsoft#11288. Keep the shared internal helper provider from microsoft#11285, but let provider-graph reachability determine whether helpers are emitted.

This reverts commit 0540648.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c4b68173-2f2b-467d-9a94-9be9d14b5e17
iscai-msft pushed a commit to iscai-msft/typespec that referenced this pull request Jul 23, 2026
…11288)

## Summary

- restore the provider-graph reference map after its main-branch
rollback in microsoft#11282, preserving the performance improvement over
Roslyn-based generated-source analysis
- keep all follow-up compatibility fixes already developed in this PR:
  - preserve concrete and nested discriminator variants
- distinguish metadata-only union items erased to `BinaryData` from
semantic public and implementation dependencies
- retain generated types that were public in the configured last GA
contract, including effectively public nested types
- preserve the owning model's accessibility when serialization partial
providers have different default modifiers
- derive collection-header helper dependencies from the selected
`HttpRequestApi`, avoiding unused `PipelineRequestHeadersExtensions`
output
- reconcile microsoft#11285 with the restored provider graph:
- retain its shared `InternalHelperProvider` modifiers and lazy helper
construction
- preserve its intentional non-root registration so generator-owned
internal helpers remain emitted without becoming accessibility roots
- add positive and negative coverage for accessibility, retention, GA
contracts, nested effective accessibility, serialization ownership,
metadata-only references, and request-helper dependencies

Fixes microsoft#11291.

## Main-branch reconciliation

This branch merges current `main` and explicitly reverts squash commit
`05406488b` from microsoft#11282. The existing microsoft#11288 commits remain intact as
follow-up commits rather than being rebased or squashed away.

## Validation

- passed 1,712 core generator tests and 1,504 ClientModel tests
- passed package build, full C# test-library regeneration, formatting,
Cop, and type-aware oxlint
- regenerated all 46 Azure and unbranded data-plane libraries with
`RegenPreview.ps1`: 46 passed, 0 failed, with no untracked files or
unexpected request helpers
- repeated the full SDK regeneration from latest Azure SDK `main`; the
resulting 72-file expected patch was byte-for-byte identical
- reproduced the service-wide Purview generation command with the local
generator; it completed successfully and produced only the expected
DataMap helper removal
- regenerated App Configuration and Projects.Agents after restoring
microsoft#11285 helper retention; representative internal helper files remain
byte-for-byte unchanged while the valid reference-map cleanup remains

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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