Harden C# type-name shadow resolution - #3869
Conversation
Plan namespace and lexical shadowing across complete output units, preserve qualified identity when imports are unsafe, and emit global aliases when ordinary qualification would rebind. Add formatter, type-printer, nested-scope, primary-constructor, attribute, delegate, and compile-back regressions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Fold delegate planning into the existing declaration entry point and keep planner context as fields so the pinned RenderMemberUnit token remains stable. Update the unaffected downstream corpus token for the intentional helper-method additions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
|
Review round at
Resolved in |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
|
Review round at Resolved in |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
…adowing # Conflicts: # tools/DecompilerHarness/corpus/two-row-authored-corpus.jsonl
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
|
Round 5 findings reconciled at
A follow-up audit caught and corrected two overreaches before settlement: hidden attributes remain analysis evidence, and explicit-interface qualifiers remain non-shortenable. Exact-head local evidence after integrating current |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
|
Round-six reconciliation at settled head
Validation at this head: Release solution build; 402 C# tests; 3,128 CLI tests; 557 ReturnToSender/authored-corpus focused tests; 4,867 full decompiler tests. Authored-corpus identity was remeasured ( |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
|
Round-seven reconciliation, now settled at exact head
After the findings, current |
Preserve binding across imported nested type paths, unit-wide attribute suffix lookup, raw string literals, and global nested declarations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Round eight reconciliationRound eight began against Findings resolved
The fixes are in Quick-read dispositionA subsequent non-formal MAI-Code quick-read reported that a dotted attribute value should itself synthesize a using for a matching declared nested type. I reproduced the output but dismissed the requested behavior: dotted attribute values are intentionally qualification-only evidence and cannot prove namespace-versus-nested-type provenance. A negative regression now verifies that attribute-value text alone does not drive an import; an independently established safe import still preserves the declared nested path. Current-head evidence
Round eight is reconciled but not clean at the current fixed head. Per the six-round limit, a ninth formal round requires fresh user approval. |
Only exempt a declared simple name when it identifies one exact top-level declaration, preserving qualification across sibling namespaces, generic arity, and nested paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Round nine reconciliationRound nine reviewed exact base Claude Opus 5 finding — fixedClaude found a high-severity silent rebinding case in the declared-type import exception. Given declarations for I reproduced the semantic mismatch on the untouched review head and confirmed the base kept GPT-5.6 Sol finding — dismissed as pre-existingGPT reported that A non-formal MAI-Code quick-read of the follow-up found no additional defect. Fixed-head evidence for
|
…-type-name-shadowing
|
Round-10 carry-forward update: integrated exact |
|
Correction to the immediately preceding carry-forward note: the merge head is |
…-type-name-shadowing
|
Round-10 carry-forward update: integrated exact |
…-type-name-shadowing
|
Round-10 carry-forward update: integrated exact |
Resolve the C# printer and ReturnToSender conflicts by retaining complete-unit binding-safe type planning while carrying the product-owned frozen body replacement range through rendered fragments and compile-back diagnostics. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
|
Resolved in merge commit Validation at the merge head: Release solution build; 423/423 C# planner/artifact tests; 4,939/4,939 decompiler tests; and 3,319 passed CLI tests with 4 platform skips. Because this was an overlapping conflict resolution, round 10 cannot carry across it; a fresh round 11 is required after current-head CI is green. |
…-type-name-shadowing
|
Integrated current Validation at the new head: Release solution build; 424/424 C# planner/artifact tests; and 207/207 focused ReturnToSender prototype tests. Current-head CI remains required before round 11 can begin. |
Adversarial review round 11 — clean at
|
Preserve complete-unit binding-safe planning and frozen source artifacts while adopting collision-safe immutable sorted using sets. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Integrate the repository-wide .NET 11 Preview 6 CI pin after the Preview 7 channel rollover invalidated existing union patterns. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Integrate annotated source node-kind and printer range-map changes after validating the type planner and compile-back source artifact boundary. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Treat unqualified type-position names as collision evidence, preserve ambiguous parenthesized attribute values, and recognize declared paths visible through ancestor namespaces. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Avoid shortening a type declared in another namespace when any second namespace is imported, since namespace-only using inputs cannot prove that the simple name remains unambiguous. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Preserve qualification for delegate and primary-constructor references when a second configured or derived namespace can make their newly shortened names ambiguous. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Keep delegate constraints and primary-constructor types qualified unless configured, declared, or existing unit evidence establishes their dotted prefix as a namespace. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3787daf2-0222-4f9a-ab24-90df5356dccc
|
Review reconciliation for the final fixed-head round:
Ready to merge |
Closes #3800.
C# declaration output now plans type-name collisions against the complete selected output unit, including caller imports, namespace visibility, primary constructors, nested declarations, generic parameters, attributes, and delegates. Ambiguous or shadowed identities remain qualified, and qualified fallbacks receive
global::only when ordinary qualification would rebind.The public policy API and default remain unchanged. Safe same-namespace, sibling-type, unrelated-namespace-child, contextual-import, and cross-declaring-namespace shortening remain enabled; no aliases are synthesized.
Validation:
dotnet run --project src/ILInspector.CSharp.Tests -c Release— 512 passeddotnet build dotnet-inspect.slnx -c Releasedotnet run --project src/ILInspector.Decompiler.Tests -c Release --no-build -- -class ILInspector.Decompiler.Tests.ReturnToSenderPrototypeTests— 197 passed