Skip to content

perf(http-client-csharp): avoid Roslyn simplifier for type names#10916

Draft
ArcturusZhang wants to merge 3 commits into
microsoft:mainfrom
ArcturusZhang:arcturus/csharp-generator-type-name-resolver
Draft

perf(http-client-csharp): avoid Roslyn simplifier for type names#10916
ArcturusZhang wants to merge 3 commits into
microsoft:mainfrom
ArcturusZhang:arcturus/csharp-generator-type-name-resolver

Conversation

@ArcturusZhang
Copy link
Copy Markdown
Member

This PR adds an emission-time C# type-name analyzer for the http-client-csharp generator. It collects type references per generated file, resolves safe imports/qualifications with a namespace prefix trie, omits global:: in the optimized path, and skips Roslyn Simplifier.ReduceAsync when no custom Roslyn rewriters are registered.

Validation:

  • dotnet build packages/http-client-csharp/generator
  • dotnet test packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Microsoft.TypeSpec.Generator.Tests.csproj --filter FullyQualifiedName!~GeneratorHandlerTests
  • dotnet test packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Microsoft.TypeSpec.Generator.ClientModel.Tests.csproj

Note: full Microsoft.TypeSpec.Generator.Tests has plugin-build tests blocked locally because this machine has .NET SDK 10.0.300 while the repo global.json requests 10.0.103 with latestPatch roll-forward.

Emit C# type names through a per-file analyzer that collects referenced types, uses a namespace prefix trie to choose safe imports/qualifications, and omits global:: in the optimized path. Skip Roslyn Simplifier.ReduceAsync when no custom rewriters require it.

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 Jun 8, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 8, 2026

Open in StackBlitz

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

commit: b96896c

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 8, 2026

No changes needing a change description found.

ArcturusZhang and others added 2 commits June 8, 2026 13:52
Resolve ambiguous type names with full namespace qualification instead of invalid namespace suffixes, and emit compound assignment statements without parentheses so generated code remains compilable without Roslyn simplification.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep expression statement writing unchanged for now and leave non-type Roslyn simplifications out of the type-name resolver change.

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.

1 participant