Skip to content

[http-client-csharp] Add bounded post-writing reduction for enclosing static qualifiers - #12751

Closed
Wei Hu (live1206) wants to merge 30 commits into
microsoft:mainfrom
live1206:issue/enclosing-static-qualifier-reduction
Closed

Wei Hu (live1206) wants to merge 30 commits into
microsoft:mainfrom
live1206:issue/enclosing-static-qualifier-reduction

Conversation

@live1206

Copy link
Copy Markdown
Contributor

Related to #12454 and #12711.

Stacked on #12707 (prototype/selective-hybrid-reduction); rebase onto main once #12707 merges.

Summary

  • Add EnclosingStaticQualifierReductionRule and SyntaxNodeBuckets.EnclosingStaticMemberCandidates to remove redundant enclosing-type and base-class static qualifiers (Foo.Validate(id) and global::Ns.Foo.Validate(id) → Validate(id)), running before StaticMemberReceiverReductionRule so global::Ns.Foo.Member collapses directly in one pass.
  • Verify unqualified symbol and invocation/outer-overload binding equivalence using the Stage-1 SemanticModel, with guards for:
    • Parameter/local shadowing, derived-class hiding (new static), and CS0135 invariant-meaning-in-blocks conflicts across the outermost enclosing declaration space (including nested lambdas and local functions).
    • Multi-overload method groups (CandidateSymbols.Length == 1 required), invoked delegate-typed members (C.nameof(x)), Color-Color member-access ambiguities, await-in-async, trivia/annotations, and SourceObservationSafety.
  • Compose with GenericTypeArgumentReductionRule via BoundedPostReducer.ApplyEdit (C.Echo<global::Example.D>(v) → Echo<D>(v)).
  • Update packages/http-client-csharp/docs/bounded-post-reduction.md and add positive, retention, and native-vs-hybrid parity tests.

Validation

  • BoundedPostReduction unit & workspace parity tests (EnclosingStaticQualifierReductionTests + BoundedPostReducerWorkspaceTests.EnclosingStaticQualifiersMatchNativeRoslyn): 121/121 passed.
  • Full local test-library regeneration (Generate.ps1 + re-verified Sample-TypeSpec after review fixes): 0 diffs across all generated test projects; generator test suites (Microsoft.TypeSpec.Generator.Tests, ClientModel.Tests, Input.Tests) passed.

@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 Dec 4, 2026
@pkg-pr-new

pkg-pr-new Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: a005918

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

@live1206

Copy link
Copy Markdown
Contributor Author

Closing this draft PR based on Azure.ResourceManager.Network (3,797 files) benchmark data: even after O(1) pre-filtering by declared/base type names, EnclosingStaticQualifierReductionRule only skipped +2 additional Stage-2 documents (1,242 → 1,244) while increasing wall time (147.00 s → 160.63 s) and CPU (500.94 s → 623.84 s) due to speculative binding and CS0135 declaration-space checks on documents that still enter Stage 2 for other constructs. Leaving enclosing static qualifiers to Roslyn fallback is both simpler and faster.

- by copilot

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