C# files using a file-scoped namespace are indexed as empty (whole body silently dropped)
#3,601 opened on Jul 29, 2026
Repository metrics
- Stars
- (21,368 stars)
- PR merge metrics
- (Avg merge 18d 10h) (162 merged PRs in 30d)
Description
Version: 0.42.59.0 (5008b287e47bf791132eedfebf66bdef11e9398c)
Summary
For any C# file using the C# 10 file-scoped namespace form (namespace Foo;),
the entire file body is silently dropped from the index. Only the leading using
directives are chunked. No warning, no sync failure — the page is created and
looks healthy.
Cause
TOP_LEVEL_TYPES.c_sharp in src/core/chunkers/code.ts includes
namespace_declaration but not file_scoped_namespace_declaration. Since
chunkCodeTextFull selects semantic nodes with
root.namedChildren.filter((n) => topLevelTypes.has(n.type))
…and in the file-scoped form every declaration in the file is a child of the
unmatched file_scoped_namespace_declaration node, nothing below it is ever
visited. The block-scoped form happens to work because namespace_declaration
is listed and its node spans the whole body.
This is very likely just an oversight from before C# 10 — the block-scoped form is handled, the file-scoped one was missed.
Reproduction
Repro.cs:
using System;
namespace Demo;
public class OrderService
{
public decimal ComputeRefund(decimal amount) => amount * 0.9m;
public void Ship(string id) => Console.WriteLine(id);
}
const { chunks } = await chunkCodeTextFull(source, 'Repro.cs');
// chunks cover only the `using` line; OrderService is absent.
Real-world: a 559-line file in our codebase produced 2 chunks covering lines 1-12. The interface and class — lines 14-560 — were not in the brain at all.
Add 'file_scoped_namespace_declaration' to TOP_LEVEL_TYPES.c_sharp and the
body is recovered.
Impact
This degrades ordinary semantic search, not just the code-graph surfaces. In our
corpus 234 of 289 .cs files (81%) use the file-scoped form, so the great
majority of our C# was absent from an index that reported itself healthy —
doctor is all-green and the pages exist with plausible chunk counts. We only
found it while investigating why code_def returned nothing.
Suggested extra: since a .cs file that yields zero named symbols is almost
always a parse/config gap rather than a genuinely empty file, a debug-level
warning would have surfaced this immediately.
Our patch
deploy/patches/0001-csharp-symbols-and-call-edges.patch (13 lines) implements
both, and applies cleanly at 5008b287. It is applied at Docker build time until
this lands upstream.