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(godot): resolve scene connections to C# script methods (#2316)
Aman03645aaeee28
diff --git a/packages/core/src/repowise/core/ingestion/framework_edges/godot.py b/packages/core/src/repowise/core/ingestion/framework_edges/godot.pyindex 48ce7f0bd..a34734c69 100644--- a/packages/core/src/repowise/core/ingestion/framework_edges/godot.py+++ b/packages/core/src/repowise/core/ingestion/framework_edges/godot.py@@ -104,6 +104,10 @@ def _has_gdscript(parsed_files: dict[str, Any]) -> bool:return any(p.file_info.language == "gdscript" for p in parsed_files.values())+def _has_gdscript_or_csharp(parsed_files: dict[str, Any]) -> bool:+ return any(p.file_info.language in ("gdscript", "csharp") for p in parsed_files.values())++def _source_text(path: str, parsed: Any, source_map: dict[str, bytes]) -> str:"""Source text for *path*, preferring bytes ingestion already read.@@ -304,10 +308,12 @@ def _add_connection_edges(source_map = getattr(ctx, "source_map", None) or {}# `{script path: {function name: symbol id}}`. Methods included: GDScript# writes a handler as a plain `func`, but an inner class puts one under a- # parent, and either is a legitimate target for a connection.+ # parent, and either is a legitimate target for a connection. C# is a+ # first-class Godot scripting option too, and a scene's `[connection]`+ # block is language-agnostic, so its methods belong in the same lookup.functions: dict[str, dict[str, str]] = {}for path, parsed in parsed_files.items():- if parsed.file_info.language != "gdscript":+ if parsed.file_info.language not in ("gdscript", "csharp"):continuetable = {sym.name: sym.id@@ -372,7 +378,7 @@ class _GodotClassNameHandler:class _GodotSceneConnectionHandler:def detect(self, dctx: DetectionContext) -> bool:- return _has_gdscript(dctx.parsed_files) and any(+ return _has_gdscript_or_csharp(dctx.parsed_files) and any(p.file_info.language == "godot_resource" for p in dctx.parsed_files.values())diff --git a/tests/unit/ingestion/test_godot_project_awareness.py b/tests/unit/ingestion/test_godot_project_awareness.pyindex 3ca11db5c..d06f2a374 100644--- a/tests/unit/ingestion/test_godot_project_awareness.py+++ b/tests/unit/ingestion/test_godot_project_awareness.py@@ -443,7 +443,12 @@ def _connection_edges(tmp_path: Path, files: dict[str, str]) -> nx.DiGraph:abs_path = tmp_path / relabs_path.parent.mkdir(parents=True, exist_ok=True)abs_path.write_text(text, encoding="utf-8")- language = "gdscript" if rel.endswith(".gd") else "godot_resource"+ if rel.endswith(".gd"):+ language = "gdscript"+ elif rel.endswith(".cs"):+ language = "csharp"+ else:+ language = "godot_resource"symbols = []if language == "gdscript":for line in text.splitlines():@@ -454,6 +459,14 @@ def _connection_edges(tmp_path: Path, files: dict[str, str]) -> nx.DiGraph:SimpleNamespace(id=sym_id, name=name, kind="function"))graph.add_node(sym_id, node_type="symbol")+ elif language == "csharp":+ for line in text.splitlines():+ stripped = line.strip()+ if stripped.startswith("public void "):+ name = stripped[len("public void ") :].split("(", 1)[0].strip()+ sym_id = f"{rel}::{name}"+ symbols.append(SimpleNamespace(id=sym_id, name=name, kind="method"))+ graph.add_node(sym_id, node_type="symbol")parsed[rel] = SimpleNamespace(file_info=_file_info(rel, language, str(abs_path)),imports=[],@@ -647,6 +660,24 @@ class TestSceneConnectionEdges:)assert not graph.has_edge("main.tscn::__module__", "hud.gd::_on_start_pressed")+ def test_a_csharp_handler_binds(self, tmp_path: Path) -> None:+ # C# is a first-class Godot scripting option; a scene connecting to+ # a C# script's method must bind exactly like a GDScript handler+ # (issue #2303).+ scene = ROOT_SCRIPT_SCENE.replace("hud.gd", "Hud.cs").replace(+ 'method="_on_start_pressed"', 'method="OnPressed"'+ )+ hud_cs = (+ "public partial class Hud : CanvasLayer\n"+ "{\n"+ " public void OnPressed()\n"+ " {\n"+ " }\n"+ "}\n"+ )+ graph = _connection_edges(tmp_path, {"hud.tscn": scene, "Hud.cs": hud_cs})+ assert graph.has_edge("hud.tscn::__module__", "Hud.cs::OnPressed")+def test_the_handler_needs_a_scene(self, tmp_path: Path) -> None:parsed = {"a.gd": SimpleNamespace(