[http-client-csharp] Skip unnecessary simplifier passes#10846
Draft
live1206 wants to merge 17 commits into
Draft
[http-client-csharp] Skip unnecessary simplifier passes#10846live1206 wants to merge 17 commits into
live1206 wants to merge 17 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
commit: |
Contributor
|
No changes needing a change description found. |
Run simplification for documents containing global aliases so shared-source type names and generated sample code are reduced correctly while still skipping documents that do not need simplification. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Generate valid assignment statements without relying on Roslyn simplification, and keep shared-source test expectations aligned with the skip behavior so broad global-alias simplification is not reintroduced. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Refresh generated test projects and unit test expectations after skipping Roslyn simplification for documents without simplifier annotations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Avoid emitting a trailing space after array type syntax when the initializer is multiline. Regenerated outputs now match without manual generated-file whitespace edits. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use plain default for known cancellation token optional parameters so generated code remains valid when documents are not passed through Roslyn simplification. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Refresh remaining generator unit test baselines after removing trailing spaces from multiline array initializers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This reverts commit 6aa5e5a.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Optimize generated C# post-processing by reducing provably safe qualified names before running the full Roslyn simplifier.
The new pass targets qualified names such as
global::System.Uri/System.ClientModel.ClientResultand uses Roslyn speculative binding to replace them with the rightmost name only when the replacement binds to the same symbol in the same semantic model. Unsafe or unsupported cases are left for the normal Roslyn simplifier.This keeps generated output stable while reducing the amount of semantic name-reduction work left for
Simplifier.ReduceAsync.Motivation
While profiling Azure.ResourceManager.Network generation through the Azure management generator, Roslyn post-processing dominated the direct .NET generator run time. The hotspot was semantic name simplification / global-qualified name reduction in the shared MTG
GeneratedCodeWorkspace.ProcessDocumentpath.The no-simplifier comparison showed that
global::/ name simplification was by far the largest category: 98,190 diff blocks across 3,534 files. However, skipping or narrowing the simplifier is not a valid product fix because generated output/functionality can be missed or changed.Latest Network direct-generator measurement
Validated against the same Network saved
tspCodeModel.json/Configuration.jsondirect-generator path. A fresh no-reducer baseline and reducer run produced identicalsrc/Generatedoutput (diff -qrreturned no differences).00:19:47.501190.835s00:14:04.68847.959sPhase markers from the reducer run:
00:00:03.9400:00:11.4400:00:17.6600:14:02.9000:14:04.68Output sanity check after the Network run:
global::Systemthis.<see cref="global::Implementation notes
QualifiedNameSyntax/AliasQualifiedNameSyntaxnodes and skips unsupported contexts such asusingdirectives and XMLcref.SymbolEqualityComparer.Defaultin the same semantic model.this., parenthesized expressions, cref, qualified names, member access expressions, assignments, etc.).Validation
cd packages/http-client-csharp npm run build:generator pwsh ./eng/scripts/Generate.ps1 npm run test:generatorLocal validation results:
npm run build:generatorpassed.pwsh ./eng/scripts/Generate.ps1produced no generated test-project diffs.npm run test:generatorpassed.00:19:47.50to00:14:04.68internal time on the same saved inputs, with no generated output differences versus the fresh baseline.