Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

Commit 0da8b41

Browse files
gkorlandCopilot
andcommitted
Fix multi-line docstring collection and document base_class heuristic
- Walk back through contiguous comment siblings to collect all XML doc comment lines instead of only the last one - Add clarifying comment about the base_list heuristic limitation (cannot distinguish base class from interface without semantic analysis) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6ea8ab5 commit 0da8b41

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

api/analyzers/csharp/analyzer.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ def get_entity_name(self, node: Node) -> str:
5656
def get_entity_docstring(self, node: Node) -> Optional[str]:
5757
if node.type in ['class_declaration', 'interface_declaration', 'enum_declaration',
5858
'struct_declaration', 'method_declaration', 'constructor_declaration']:
59-
if node.prev_sibling and node.prev_sibling.type == "comment":
60-
return node.prev_sibling.text.decode('utf-8')
61-
return None
59+
# Walk back through contiguous comment siblings to collect
60+
# multi-line XML doc comments (each /// line is a separate node)
61+
lines = []
62+
sibling = node.prev_sibling
63+
while sibling and sibling.type == "comment":
64+
lines.insert(0, sibling.text.decode('utf-8'))
65+
sibling = sibling.prev_sibling
66+
return '\n'.join(lines) if lines else None
6267
raise ValueError(f"Unknown entity type: {node.type}")
6368

6469
def get_entity_types(self) -> list[str]:
@@ -72,8 +77,11 @@ def add_symbols(self, entity: Entity) -> None:
7277
first = True
7378
for base_type in base_list_captures['base_type']:
7479
if first and entity.node.type == 'class_declaration':
75-
# In C# the first item in base_list can be a base class or interface;
76-
# we treat it as base_class for classes (convention: base class listed first)
80+
# NOTE: Without semantic analysis, we cannot distinguish a base
81+
# class from an interface in C# base_list. By convention, the
82+
# base class is listed first; if a class only implements
83+
# interfaces, this will produce a spurious base_class edge that
84+
# the LSP resolution in second_pass can correct.
7785
entity.add_symbol("base_class", base_type)
7886
first = False
7987
else:

0 commit comments

Comments
 (0)