Skip to content

Fix empty namespaces in C# custom-code references to generated types - #11974

Draft
JoshLove-msft with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-empty-namespace-issue
Draft

JoshLove-msft with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-empty-namespace-issue

Conversation

Copilot AI commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Custom-code references to generated types without customization stubs resolve to Roslyn error symbols, causing model factories to emit invalid names such as global::.ToolConfig.

  • Resolution: Fall back to TypeProvidersByName for unresolved, non-generic symbols with empty namespaces. Reuse generated type metadata, preserving nullability, enum semantics, and declaring types.
  • Scope: Leave resolved types, qualified symbols, and unmatched names unchanged.
  • Coverage: Add regressions for models, fixed/extensible enums, nullable types, nested generic references, and generated factory output.
// Before
IDictionary<string, global::.ToolConfig> toolConfigs = default

// After
IDictionary<string, global::Sample.Models.ToolConfig> toolConfigs = default

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

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 15, 2026
Copilot AI changed the title [WIP] Fix empty namespace issue for custom-code references Fix empty namespaces in C# custom-code references to generated types Sep 15, 2026
Copilot AI requested a review from JoshLove-msft September 15, 2026 19:45
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.

[Bug]: Custom-code references to generated (un-stubbed) types emit empty namespace ( global::.TypeName )

2 participants