Namespaces visible to extension-method lookup, innermost level first. C# 12.8.10.3: for each enclosing namespace declaration — innermost first, ending with the compilation unit — consider that namespace and the ``using namespace`` directives declared at that level. A file-le
(self, source_node: dict, source_file: str)
| 472 | return scopes |
| 473 | |
| 474 | def visible_namespaces(self, source_node: dict, source_file: str) -> list[set[str]]: |
| 475 | """Namespaces visible to extension-method lookup, innermost level first. |
| 476 | |
| 477 | C# 12.8.10.3: for each enclosing namespace declaration — innermost first, |
| 478 | ending with the compilation unit — consider that namespace and the |
| 479 | ``using namespace`` directives declared at that level. A file-level |
| 480 | using belongs to the compilation unit, so it is only considered at the |
| 481 | outermost level; that is why an extension declared in an inner namespace |
| 482 | wins over one imported at the top of the file (#4828). |
| 483 | |
| 484 | A namespace-scoped using is treated as visible at every level inside it. |
| 485 | That is coarser than the spec but only ever adds candidates at a deeper |
| 486 | level than the directive's own, and the caller drops ties. |
| 487 | """ |
| 488 | chain = [part for part in self._namespace(source_node).split(".") if part] |
| 489 | usings = self.namespace_usings_by_file.get(source_file, []) |
| 490 | levels: list[set[str]] = [] |
| 491 | for i in range(len(chain), -1, -1): |
| 492 | visible = {".".join(chain[:i])} |
| 493 | for target_fqn, scope_kind, scope_id in usings: |
| 494 | if scope_kind == "file": |
| 495 | if i == 0: |
| 496 | visible.add(target_fqn) |
| 497 | elif self._using_in_scope(scope_kind, scope_id, source_node): |
| 498 | visible.add(target_fqn) |
| 499 | levels.append(visible) |
| 500 | return levels |
| 501 | |
| 502 | def _resolve_alias(self, label: str, source_node: dict, source_file: str) -> str | None: |
| 503 | hits = set() |
no test coverage detected