diff --git a/gitnexus/src/core/ingestion/language-config.ts b/gitnexus/src/core/ingestion/language-config.ts index 4776d897e..89da0e69d 100644 --- a/gitnexus/src/core/ingestion/language-config.ts +++ b/gitnexus/src/core/ingestion/language-config.ts @@ -324,6 +324,19 @@ export async function scanCSharpProject(repoRoot: string): Promise { + const parts: string[] = []; + const stream = createReadStream(filePath, { encoding: 'utf-8', end: maxBytes }); + for await (const part of stream) { + parts.push(part as string); + } + return parts.join(''); +} + async function readCsprojConfig( csprojPath: string, fileName: string, @@ -332,9 +345,9 @@ async function readCsprojConfig( maxFileSizeBytes: number, ): Promise { try { - const stat = await fs.stat(csprojPath); - if (stat.size > maxFileSizeBytes) return null; // oversized .csproj → skip unread - const content = await fs.readFile(csprojPath, 'utf-8'); + // `` sits in the first PropertyGroup near the top, so a + // capped read captures any real .csproj while bounding pathological input. + const content = await readFileTextCapped(csprojPath, maxFileSizeBytes); const nsMatch = content.match(CSHARP_ROOT_NAMESPACE_RE); const rootNamespace = nsMatch ? nsMatch[1].trim() : fileName.replace(/\.csproj$/, ''); const projectDir = path.relative(repoRoot, dir).replace(/\\/g, '/');