Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(csharp): bind an extension-method call to the type it extends (#2312)
Raghav Chamadiya80a989165573
diff --git a/packages/core/src/repowise/core/ingestion/call_resolver.py b/packages/core/src/repowise/core/ingestion/call_resolver.pyindex bbbab1e08..c6a74e633 100644--- a/packages/core/src/repowise/core/ingestion/call_resolver.py+++ b/packages/core/src/repowise/core/ingestion/call_resolver.py@@ -59,7 +59,11 @@ from .models import (symbol_id_language,)from .return_types import declared_return_type, normalize_return_type, signature_parameter_count-from .type_names import POINTER_LIKE_MEMBERS+from .type_names import (+ POINTER_LIKE_MEMBERS,+ csharp_extension_receiver,+ is_resolvable_type_name,+)log = structlog.get_logger(__name__)@@ -288,6 +292,16 @@ class CallResolver:# every file's method dict with one short-list lookup.self._global_methods: dict[tuple[str, str], list[tuple[str, str]]] = defaultdict(list)+ # C# extension methods, keyed on the type they extend rather than on+ # their holder class: {(type, method): (file_path, symbol_id)} and the+ # per-file view of the same. Held apart from the method index on+ # purpose — merging them would leak C# keys into the C++ and JVM tiers+ # that read ``_global_methods``, and would let an extension answer a+ # site the instance method the language dispatches to should own.+ self._extension_methods: dict[tuple[str, str], tuple[str, str]] = {}+ self._file_extension_methods: dict[str, dict[tuple[str, str], str]] = {}+ self._merged_import_extensions: dict[str, dict[tuple[str, str], str]] = {}+# Global symbol index: {name: [symbol_ids]} — for Tier 3self._global_symbols: dict[str, list[str]] = defaultdict(list)self._symbols_by_id = {@@ -318,6 +332,14 @@ class CallResolver:self._known_type_names = frozenset(symbol.name for symbol in self._symbols_by_id.values() if symbol.kind in _TYPE_KINDS)+ # Narrowed to C# for the extension index: the set above is a bare+ # cross-language name match, so a type of that name in any language+ # would admit an extension on the BCL type it shadows.+ self._csharp_type_names = frozenset(+ symbol.name+ for symbol in self._symbols_by_id.values()+ if symbol.kind in _TYPE_KINDS and symbol.language == "csharp"+ )# Symbols in the index above that are data members, not callables# Held as an id set rather than a full id->kind map: it is the only@@ -831,6 +853,9 @@ class CallResolver:# Both feed ``_link_declarations`` once every file has been indexed.definitions: dict[tuple[str | None, str], list[tuple[str, str]]] = defaultdict(list)declarations: list[tuple[str, str, tuple[str | None, str]]] = []+ # (extended type, method) -> the symbols claiming it. Settled after the+ # loop, because ambiguity is judged repo-wide.+ extensions: dict[tuple[str, str], set[tuple[str, str]]] = defaultdict(set)for path, parsed in parsed_files.items():file_syms: dict[str, str] = {}@@ -861,6 +886,18 @@ class CallResolver:file_methods[key] = sym.idself._global_methods[key].append((path, sym.id))+ extended = (+ csharp_extension_receiver(sym.signature)+ if sym.language == "csharp"+ else None+ )+ if (+ extended is not None+ and is_resolvable_type_name(extended, "csharp")+ and extended in self._csharp_type_names+ ):+ extensions[(extended, sym.name)].add((path, sym.id))+# Global indicesif sym.kind in _NON_CALLABLE_KINDS:self._non_callable_ids.add(sym.id)@@ -875,6 +912,27 @@ class CallResolver:self._file_methods[path] = file_methodsself._decl_to_def = self._link_declarations(declarations, definitions)+ self._index_extension_methods(extensions)++ def _index_extension_methods(+ self, candidates: dict[tuple[str, str], set[tuple[str, str]]]+ ) -> None:+ """Record every unambiguous extension pair; drop the rest.++ Two holder classes declaring one ``(type, method)`` are told apart by+ which ``using`` is in scope, which the graph does not model. Refusing+ costs an edge; guessing costs correctness.++ An overload set is not this case -- every overload of one method in one+ class shares a symbol id. A ``partial`` class split across files is,+ and stays refused.+ """+ for key, sites in candidates.items():+ if len({sym_id for _, sym_id in sites}) != 1:+ continue+ path, sym_id = next(iter(sites))+ self._extension_methods[key] = (path, sym_id)+ self._file_extension_methods.setdefault(path, {})[key] = sym_iddef _link_declarations(self,@@ -1016,17 +1074,63 @@ class CallResolver:def _merged_methods_for(self, file_path: str) -> dict[tuple[str, str], str]:"""Merged ``{(class, method) → symbol_id}`` across imports (see above)."""- merged = self._merged_import_methods.get(file_path)+ return self._merged_over(file_path, self._file_methods, self._merged_import_methods)++ def _merged_extension_methods_for(self, file_path: str) -> dict[tuple[str, str], str]:+ """Merged ``{(extended type, method) → symbol_id}`` across imports.++ This is the tier C# extensions actually live on: ``using`` is how a+ holder class is brought into scope, so an imported extension is better+ evidence here than the repo-wide fallback below it.+ """+ return self._merged_over(+ file_path, self._file_extension_methods, self._merged_import_extensions+ )++ def _merged_over(+ self,+ file_path: str,+ per_file: dict[str, dict[tuple[str, str], str]],+ cache: dict[str, dict[tuple[str, str], str]],+ ) -> dict[tuple[str, str], str]:+ """One import-merged view over a per-file ``(pair → symbol_id)`` index.++ First import wins, in sorted order, so the merge is deterministic.+ """+ merged = cache.get(file_path)if merged is None:merged = {}for imported_file in sorted(self._import_targets.get(file_path, ())):if imported_file.startswith("external:"):continue- for key, sym_id in self._file_methods.get(imported_file, {}).items():+ for key, sym_id in per_file.get(imported_file, {}).items():merged.setdefault(key, sym_id)- self._merged_import_methods[file_path] = merged+ cache[file_path] = mergedreturn merged+ def _extension_target(self, file_path: str, key: tuple[str, str]) -> tuple[str, str] | None:+ """The extension method a ``(type, method)`` pair names, and its scope.++ Same three scopes as ``_receiver_pair_match``, over the extension index.+ """+ site = self._extension_methods.get(key)+ if site is None:+ return None+ type_name, method_name = key+ # An import bound the name outside the repo, so a local holder of the+ # same simple name is not what the call site named.+ if type_name in self._externally_bound_names(file_path):+ return None+ if self._inherits_the_method(type_name, method_name):+ return None+ own = self._file_extension_methods.get(file_path, {})+ if key in own:+ return own[key], "same_file"+ merged = self._merged_extension_methods_for(file_path)+ if key in merged:+ return merged[key], "import"+ return site[1], "global"+def resolve_file(self, file_path: str, calls: list[CallSite]) -> list[ResolvedCall]:"""Resolve all calls in a single file to symbol-level edges."""results: list[ResolvedCall] = []@@ -1790,7 +1894,13 @@ class CallResolver:found = self._typed_receiver_target(file_path, call, caller_id, type_name)if found is None:- return None+ # Last, because C# prefers an instance method to an extension.+ if language != "csharp":+ return None+ extension = self._extension_target(file_path, (type_name, call.target_name))+ if extension is None:+ return None+ return self._extension_typed_call(caller_id, *extension, call.line)sym_id, tier = foundif from_framework:return self._framework_typed_call(caller_id, sym_id, tier, call.line)@@ -1856,6 +1966,37 @@ class CallResolver:return ResolvedCall(caller_id, sym_id, 0.88, line, "receiver_framework_import")return ResolvedCall(caller_id, sym_id, 0.75, line, "receiver_framework_global")+ def _inherits_the_method(self, type_name: str, method_name: str) -> bool:+ """Could a class of this name reach *method_name* through an ancestor?++ C# dispatches to an inherited instance method in preference to an+ extension, and every tier above asks only for the literal+ ``(type, method)`` pair, so none of them sees one. Asked of every class+ sharing the simple name: which is meant is not settled here.+ """+ for sym_id in self._global_symbols.get(type_name, ()):+ symbol = self._symbols_by_id.get(sym_id)+ if symbol is None or symbol.kind not in _TYPE_KINDS:+ continue+ if any(self._declares(a, method_name) for a in self._ancestors_of(sym_id)):+ return True+ return False++ def _extension_typed_call(+ self, caller_id: str, sym_id: str, tier: str, line: int+ ) -> ResolvedCall:+ """Stamp an edge onto a C# extension method.++ One family whatever scope typed the receiver, unlike the three-way+ typed/field/framework split above: what an audit needs to separate is+ the extension binding, whose holder class no call site mentions.+ """+ if tier == "same_file":+ return ResolvedCall(caller_id, sym_id, 0.93, line, "receiver_extension_same_file")+ if tier == "import":+ return ResolvedCall(caller_id, sym_id, 0.88, line, "receiver_extension_import")+ return ResolvedCall(caller_id, sym_id, 0.75, line, "receiver_extension_global")+def _method_names(self) -> frozenset[str]:"""Every name declared as a method of some class, built once."""if self._method_name_set is None:diff --git a/packages/core/src/repowise/core/ingestion/models.py b/packages/core/src/repowise/core/ingestion/models.pyindex fbc4742e5..1b7127cec 100644--- a/packages/core/src/repowise/core/ingestion/models.py+++ b/packages/core/src/repowise/core/ingestion/models.py@@ -453,6 +453,13 @@ ResolutionOrigin = Literal["receiver_framework_same_package", # 0.90"receiver_framework_import", # 0.88"receiver_framework_global", # 0.75+ # A C# extension method, reached through the type its ``this`` parameter+ # names rather than the static class holding it. One family, not a fourth+ # set of four: no same-package tier reaches the extension index. Separable+ # because the holder class is a file no call site names.+ "receiver_extension_same_file", # 0.93+ "receiver_extension_import", # 0.88 — the holder class's file is imported+ "receiver_extension_global", # 0.75 — declared somewhere; a name match# Chained receiver typed from the inner callee's declared return type."return_type_same_file", # 0.93"return_type_same_package", # 0.90 (JVM)diff --git a/packages/core/src/repowise/core/ingestion/type_names.py b/packages/core/src/repowise/core/ingestion/type_names.pyindex 4ce3f52e2..238ff0f8e 100644--- a/packages/core/src/repowise/core/ingestion/type_names.py+++ b/packages/core/src/repowise/core/ingestion/type_names.py@@ -24,6 +24,8 @@ This module is a leaf: it reads the language registry and nothing else.from __future__ import annotations+import re+from .language_data import get_builtin_types# A qualifier separator in any language we parse. PHP's ``\`` is here rather@@ -168,3 +170,31 @@ def is_resolvable_type_name(name: str, language: str) -> bool:if name in get_builtin_types(language):return Falsereturn not (len(name) == 1 and name.isupper())+++# The receiver of a C# extension method, as the parameter list spells it.+# ``this`` is legal only on an extension method's first parameter, and the+# parser keeps no modifiers, so this is the only surviving evidence a method is+# one. Matched against the parameter list alone, because a default value may+# hold a parenthesised string. An array receiver is captured so it can be+# refused: ``this Order[]`` extends the array, not the element.+_CSHARP_EXTENSION_RECEIVER = re.compile(+ r"\s*this\s+(?:(?:ref|in|scoped|readonly)\s+)*"+ r"(?P<type>[\w.]+(?:<[^>]*>)?(?:\s*\[[,\s]*\])*\??)"+)+++def csharp_extension_receiver(signature: str) -> str | None:+ """The bare type a C# extension method extends, or None if it is not one.++ Shape only, in keeping with this module: whether the name could resolve is+ the caller's policy, not this module's.+ """+ _, opened, params = (signature or "").partition("(")+ match = _CSHARP_EXTENSION_RECEIVER.match(params) if opened else None+ if match is None:+ return None+ raw = match.group("type")+ if "[" in raw:+ return None+ return bare_type_name(raw.rstrip("?")) or Nonediff --git a/packages/server/src/repowise/server/mcp_server/_basis.py b/packages/server/src/repowise/server/mcp_server/_basis.pyindex 91354bf8d..5a31cf766 100644--- a/packages/server/src/repowise/server/mcp_server/_basis.py+++ b/packages/server/src/repowise/server/mcp_server/_basis.py@@ -30,6 +30,7 @@ GUESSED_ORIGINS: frozenset[str] = frozenset({"global_unique","receiver_global",+ "receiver_extension_global","receiver_typed_global","receiver_field_global","receiver_framework_global",diff --git a/packages/types/src/graph.ts b/packages/types/src/graph.tsindex 47a5cbf0d..f3fcabc5c 100644--- a/packages/types/src/graph.ts+++ b/packages/types/src/graph.ts@@ -310,6 +310,9 @@ export type ResolutionOrigin =| "receiver_framework_same_package"| "receiver_framework_import"| "receiver_framework_global"+ | "receiver_extension_same_file"+ | "receiver_extension_import"+ | "receiver_extension_global"| "return_type_same_file"| "return_type_same_package"| "return_type_import"diff --git a/packages/ui/__tests__/graph/edge-provenance.test.ts b/packages/ui/__tests__/graph/edge-provenance.test.tsindex 918bfd764..61d39f93f 100644--- a/packages/ui/__tests__/graph/edge-provenance.test.ts+++ b/packages/ui/__tests__/graph/edge-provenance.test.ts@@ -51,6 +51,9 @@ const ALL_ORIGINS: ResolutionOrigin[] = ["receiver_framework_same_package","receiver_framework_import","receiver_framework_global",+ "receiver_extension_same_file",+ "receiver_extension_import",+ "receiver_extension_global","return_type_same_file","return_type_same_package","return_type_import",@@ -108,6 +111,7 @@ describe("isNameMatch", () => {expect(marked.sort()).toEqual(["global_unique",+ "receiver_extension_global","receiver_field_global","receiver_framework_global","receiver_global",diff --git a/packages/ui/src/graph/edge-provenance.ts b/packages/ui/src/graph/edge-provenance.tsindex d05be7734..edba2f034 100644--- a/packages/ui/src/graph/edge-provenance.ts+++ b/packages/ui/src/graph/edge-provenance.ts@@ -66,6 +66,11 @@ const ORIGINS = {because: "a framework decorator retyped the receiver, and that class is in this file",tier: "direct",},+ receiver_extension_same_file: {+ label: "Extension method, same file",+ because: "an extension method in this file extends the receiver's type",+ tier: "direct",+ },return_type_same_file: {label: "Return type, same file",because: "the inner call's declared return type is a class in this file",@@ -128,6 +133,11 @@ const ORIGINS = {because: "the receiver's declared type is a class in the same package",tier: "scoped",},+ receiver_extension_import: {+ label: "Extension method, imported",+ because: "an imported file extends the receiver's type with this method",+ tier: "scoped",+ },receiver_typed_import: {label: "Inferred type, imported",because: "the receiver's declared type was found in an imported file",@@ -180,6 +190,11 @@ const ORIGINS = {because: "that class and method pair exists somewhere in the repo",tier: "name_match",},+ receiver_extension_global: {+ label: "Name match",+ because: "one extension method in the repo extends this type with this name",+ tier: "name_match",+ },receiver_typed_global: {label: "Name match",because: "the inferred type and method pair exists somewhere in the repo",diff --git a/tests/unit/ingestion/test_csharp_extension_methods.py b/tests/unit/ingestion/test_csharp_extension_methods.pynew file mode 100644index 000000000..cefbeff16--- /dev/null+++ b/tests/unit/ingestion/test_csharp_extension_methods.py@@ -0,0 +1,281 @@+"""Binding a C# extension-method call to the type its ``this`` parameter names.++The method index keys on the containing class, so ``static class+OrderExtensions { decimal NetTotal(this Order o) }`` only ever minted+``("OrderExtensions", "NetTotal")`` while the call site ``o.NetTotal()`` asks+for ``("Order", "NetTotal")``. Nothing wrote that key, so the site produced no+edge at all.++The resolver reads the receiver's declared type off the file text, so these+tests write real files and hand the resolver a repo path rather than parsing+in memory.+"""++from __future__ import annotations++from datetime import datetime+from pathlib import Path++import pytest++from repowise.core.ingestion.call_resolver import CallResolver+from repowise.core.ingestion.models import FileInfo+from repowise.core.ingestion.parser import ASTParser+from repowise.core.ingestion.type_names import csharp_extension_receiver++ORDER = "namespace Acme;\npublic class Order { public decimal Amount; }\n"+++def _resolve(+ tmp_path: Path,+ files: dict[str, str],+ caller: str,+ imports: dict[str, set[str]] | None = None,+ heritage: dict[str, set[str]] | None = None,+) -> dict[str, tuple[str, float]]:+ """``{method name: (origin, confidence)}`` for every call the caller makes."""+ for rel, text in files.items():+ path = tmp_path / rel+ path.parent.mkdir(parents=True, exist_ok=True)+ path.write_text(text, encoding="utf-8")++ parser = ASTParser()+ parsed = {}+ for rel, text in files.items():+ info = FileInfo(+ path=rel,+ abs_path=str(tmp_path / rel),+ language="go" if rel.endswith(".go") else "csharp",+ size_bytes=len(text),+ git_hash="",+ last_modified=datetime.now(),+ is_test=False,+ is_config=False,+ is_api_contract=False,+ is_entry_point=False,+ )+ parsed[rel] = parser.parse_file(info, text.encode())++ resolver = CallResolver(+ parsed, imports or {}, repo_path=str(tmp_path), heritage_parents=heritage+ )+ by_callee = {}+ for resolved in resolver.resolve_file(caller, parsed[caller].calls):+ by_callee[resolved.callee_id.rpartition("::")[2]] = (+ resolved.origin,+ resolved.confidence,+ )+ return by_callee+++class TestExtensionReceiver:+ """The pure helper, which reports shape and applies no policy."""++ @pytest.mark.parametrize(+ ("signature", "expected"),+ [+ ("NetTotal(this Order o, bool x = false) -> decimal", "Order"),+ ("Tail(this Acme.Domain.Order o) -> string", "Order"),+ ("First(this IEnumerable<T> src) -> T", "IEnumerable"),+ ("Use(this scoped ref readonly Order o) -> int", "Order"),+ ("Maybe(this Order? o) -> string", "Order"),+ # Not an extension method at all.+ ("Compute(int qty, string code) -> decimal", None),+ ("NoParams() -> void", None),+ # ``this`` must be a modifier, not the head of a type name.+ ("Trap(thisNotAModifier x) -> int", None),+ # An array extends the array, not the element.+ ("Sum(this Order[] orders) -> decimal", None),+ ],+ )+ def test_reports_the_extended_type(self, signature: str, expected: str | None) -> None:+ assert csharp_extension_receiver(signature) == expected+++class TestTiers:+ def test_same_file(self, tmp_path: Path) -> None:+ files = {+ "src/Order.cs": ORDER,+ "src/Ext.cs": (+ "namespace Acme;\npublic static class Ext {\n"+ " public static int Net(this Order o) { return 1; }\n"+ " public static void Run() { Order o = new Order(); var z = o.Net(); }\n"+ "}\n"+ ),+ }+ found = _resolve(tmp_path, files, "src/Ext.cs")+ assert found["Net"] == ("receiver_extension_same_file", 0.93)++ def test_imported(self, tmp_path: Path) -> None:+ files = {+ "src/Order.cs": ORDER,+ "src/Ext.cs": (+ "namespace Acme;\npublic static class Ext {\n"+ " public static int Net(this Order o) { return 1; }\n}\n"+ ),+ "src/Consumer.cs": (+ "namespace Acme;\npublic class Consumer {\n"+ " public void Run() { Order o = new Order(); var z = o.Net(); }\n}\n"+ ),+ }+ imports = {"src/Consumer.cs": {"src/Order.cs", "src/Ext.cs"}}+ found = _resolve(tmp_path, files, "src/Consumer.cs", imports)+ assert found["Net"] == ("receiver_extension_import", 0.88)++ def test_global(self, tmp_path: Path) -> None:+ """No import binds the holder, so only the repo-wide pair answers."""+ files = {+ "src/Order.cs": ORDER,+ "src/Ext.cs": (+ "namespace Acme;\npublic static class Ext {\n"+ " public static int Net(this Order o) { return 1; }\n}\n"+ ),+ "src/Consumer.cs": (+ "namespace Acme;\npublic class Consumer {\n"+ " public void Run() { Order o = new Order(); var z = o.Net(); }\n}\n"+ ),+ }+ found = _resolve(tmp_path, files, "src/Consumer.cs")+ assert found["Net"] == ("receiver_extension_global", 0.75)++ def test_an_instance_method_outranks_an_extension(self, tmp_path: Path) -> None:+ """C# dispatches to the instance method, so the extension must not answer."""+ files = {+ "src/Order.cs": (+ "namespace Acme;\npublic class Order { public int Net() { return 1; } }\n"+ ),+ "src/Ext.cs": (+ "namespace Acme;\npublic static class Ext {\n"+ " public static int Net(this Order o) { return 2; }\n}\n"+ ),+ "src/Consumer.cs": (+ "namespace Acme;\npublic class Consumer {\n"+ " public void Run() { Order o = new Order(); var z = o.Net(); }\n}\n"+ ),+ }+ imports = {"src/Consumer.cs": {"src/Order.cs", "src/Ext.cs"}}+ assert _resolve(tmp_path, files, "src/Consumer.cs")["Net"] == (+ "receiver_typed_global",+ 0.75,+ )+ assert _resolve(tmp_path, files, "src/Consumer.cs", imports)["Net"] == (+ "receiver_typed_import",+ 0.88,+ )+++class TestRefusals:+ def test_refuses_a_generic_type_parameter(self, tmp_path: Path) -> None:+ """``this T source`` would otherwise bind every receiver in the repo."""+ files = {+ "src/Order.cs": ORDER,+ "src/Ext.cs": (+ "namespace Acme;\npublic static class Ext {\n"+ " public static T Pick<T>(this T src) { return src; }\n}\n"+ ),+ "src/Consumer.cs": (+ "namespace Acme;\npublic class Consumer {\n"+ " public void Run() { Order o = new Order(); var z = o.Pick(); }\n}\n"+ ),+ }+ assert "Pick" not in _resolve(tmp_path, files, "src/Consumer.cs")++ def test_refuses_a_bcl_receiver(self, tmp_path: Path) -> None:+ files = {+ "src/Ext.cs": (+ "namespace Acme;\npublic static class Ext {\n"+ " public static string Slug(this string s) { return s; }\n}\n"+ ),+ "src/Consumer.cs": (+ "namespace Acme;\npublic class Consumer {\n"+ ' public void Run() { string s = "x"; var z = s.Slug(); }\n}\n'+ ),+ }+ assert "Slug" not in _resolve(tmp_path, files, "src/Consumer.cs")++ def test_refuses_when_the_receiver_inherits_the_method(self, tmp_path: Path) -> None:+ """C# prefers an inherited instance method, and no tier above sees one."""+ files = {+ "src/Base.cs": (+ "namespace Acme;\npublic class BaseOrder { public int Net() { return 1; } }\n"+ ),+ "src/Order.cs": "namespace Acme;\npublic class Order : BaseOrder { }\n",+ "src/Ext.cs": (+ "namespace Acme;\npublic static class Ext {\n"+ " public static int Net(this Order o) { return 2; }\n}\n"+ ),+ "src/Consumer.cs": (+ "namespace Acme;\npublic class Consumer {\n"+ " public void Run() { Order o = new Order(); var z = o.Net(); }\n}\n"+ ),+ }+ heritage = {"src/Order.cs::Order": {"src/Base.cs::BaseOrder"}}+ assert "Net" not in _resolve(tmp_path, files, "src/Consumer.cs", heritage=heritage)++ def test_a_default_value_is_not_a_parameter_list(self, tmp_path: Path) -> None:+ """A parenthesised string in a default value must not mint a pair."""+ files = {+ "src/Order.cs": ORDER,+ "src/Auditor.cs": (+ "namespace Acme;\npublic class Auditor {\n"+ ' public void Log(string message = "(this Order was rejected)") { }\n}\n'+ ),+ "src/Consumer.cs": (+ "namespace Acme;\npublic class Consumer {\n"+ " public void Run() { Order o = new Order(); o.Log(); }\n}\n"+ ),+ }+ assert "Log" not in _resolve(tmp_path, files, "src/Consumer.cs")++ def test_a_type_of_that_name_in_another_language_does_not_count(+ self, tmp_path: Path+ ) -> None:+ """The receiver must be declared in C#, not merely somewhere in the repo."""+ files = {+ "src/task.go": "package main\n\ntype Task struct {}\n",+ "src/Ext.cs": (+ "namespace Acme;\npublic static class Ext {\n"+ " public static void Forget(this Task t) { }\n}\n"+ ),+ "src/Consumer.cs": (+ "namespace Acme;\npublic class Consumer {\n"+ " public void Run() { Task t = new Task(); t.Forget(); }\n}\n"+ ),+ }+ assert "Forget" not in _resolve(tmp_path, files, "src/Consumer.cs")++ def test_ambiguity_is_terminal(self, tmp_path: Path) -> None:+ """Two holders declaring one pair: C# picks by ``using`` scope, we cannot."""+ files = {+ "src/Order.cs": ORDER,+ "src/One.cs": (+ "namespace Acme;\npublic static class One {\n"+ " public static int Dup(this Order o) { return 1; }\n}\n"+ ),+ "src/Two.cs": (+ "namespace Acme;\npublic static class Two {\n"+ " public static int Dup(this Order o) { return 2; }\n}\n"+ ),+ "src/Consumer.cs": (+ "namespace Acme;\npublic class Consumer {\n"+ " public void Run() { Order o = new Order(); var z = o.Dup(); }\n}\n"+ ),+ }+ assert "Dup" not in _resolve(tmp_path, files, "src/Consumer.cs")++ def test_an_overload_set_is_not_ambiguous(self, tmp_path: Path) -> None:+ """Every overload in one class shares a symbol id, so the pair survives."""+ files = {+ "src/Order.cs": ORDER,+ "src/Ext.cs": (+ "namespace Acme;\npublic static class Ext {\n"+ " public static int Net(this Order o) { return 1; }\n"+ " public static int Net(this Order o, bool round) { return 2; }\n}\n"+ ),+ "src/Consumer.cs": (+ "namespace Acme;\npublic class Consumer {\n"+ " public void Run() { Order o = new Order(); var z = o.Net(); }\n}\n"+ ),+ }+ found = _resolve(tmp_path, files, "src/Consumer.cs")+ assert found["Net"] == ("receiver_extension_global", 0.75)