PinkRooster.Extensions.DataIngestion.CodeAnalysis 1.0.0-preview.3

This is a prerelease version of PinkRooster.Extensions.DataIngestion.CodeAnalysis.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package PinkRooster.Extensions.DataIngestion.CodeAnalysis --version 1.0.0-preview.3
                    
NuGet\Install-Package PinkRooster.Extensions.DataIngestion.CodeAnalysis -Version 1.0.0-preview.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PinkRooster.Extensions.DataIngestion.CodeAnalysis" Version="1.0.0-preview.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PinkRooster.Extensions.DataIngestion.CodeAnalysis" Version="1.0.0-preview.3" />
                    
Directory.Packages.props
<PackageReference Include="PinkRooster.Extensions.DataIngestion.CodeAnalysis" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PinkRooster.Extensions.DataIngestion.CodeAnalysis --version 1.0.0-preview.3
                    
#r "nuget: PinkRooster.Extensions.DataIngestion.CodeAnalysis, 1.0.0-preview.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PinkRooster.Extensions.DataIngestion.CodeAnalysis@1.0.0-preview.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PinkRooster.Extensions.DataIngestion.CodeAnalysis&version=1.0.0-preview.3&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=PinkRooster.Extensions.DataIngestion.CodeAnalysis&version=1.0.0-preview.3&prerelease
                    
Install as a Cake Tool

PinkRooster logo

PinkRooster.Extensions.DataIngestion.CodeAnalysis

Roslyn-based C# source code document reader and syntax-aware AST chunker for Microsoft.Extensions.DataIngestion.

Status: release, developed against the .NET 10 SDK and Roslyn Microsoft.CodeAnalysis.CSharp.

dotnet add package PinkRooster.Extensions.DataIngestion.CodeAnalysis --prerelease

Overview

PinkRooster.Extensions.DataIngestion.CodeAnalysis brings syntax-aware source code intelligence to Microsoft RAG ingestion pipelines:

  • SourceCodeDocumentReader: Ingestion document reader for C# files (.cs), extracting root type hierarchies, documentation comments, and code structures into an IngestionDocument.
  • RoslynCodeChunker: Syntax-aware code chunker leveraging the Roslyn Abstract Syntax Tree (AST). It splits methods, properties, records, and types on natural grammatical boundaries rather than arbitrary line counts, while embedding symbol breadcrumbs (Namespace.Class.Method) into chunk.Context for accurate retrieval matching.

Quickstart

using System.Text;
using Microsoft.Extensions.DataIngestion;
using Microsoft.ML.Tokenizers;
using PinkRooster.Extensions.DataIngestion.CodeAnalysis;

var tokenizer = TiktokenTokenizer.CreateForModel("gpt-4o");

var reader = new SourceCodeDocumentReader();
const string sourceCode = """
    namespace MyApp.Services;

    public sealed class OrderProcessor
    {
        public bool ProcessOrder(int orderId) => orderId > 0;
    }
    """;

using var stream = new MemoryStream(Encoding.UTF8.GetBytes(sourceCode));
IngestionDocument doc = await reader.ReadAsync(stream, "OrderProcessor.cs", "text/x-csharp");

var chunkerOptions = new RoslynChunkerOptions(tokenizer)
{
    MaxTokensPerChunk = 128,
    IncludeEnclosingTypeSignature = true,
};

var chunker = new RoslynCodeChunker(chunkerOptions);

await foreach (IngestionChunk<string> chunk in chunker.ProcessAsync(doc))
{
    Console.WriteLine($"Symbol: {chunk.Context}");
    Console.WriteLine($"Content:\n{chunk.Content}");
}

Features

  • Grammar-Aware Splitting: Preserves syntax node integrity (method signatures, type declarations, attributes, and doc comments).
  • Symbol Breadcrumbs: Automatically annotates each chunk with its fully-qualified member context (chunk.Context).
  • Conditional Compilation Metadata: Chunks inside #if blocks carry their active preprocessor symbols under ChunkMetadataKeys.ConditionalSymbols (conditional_symbols), a constant from the Chunkers package.
  • Enclosing Type Context: Optionally retains enclosing type declaration signatures when sub-chunking oversized method bodies.

Compatibility

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.4 57 11/21/2026
1.0.0-preview.3 50 11/20/2026
1.0.0-preview.2 55 11/20/2026
1.0.0-preview.1 58 11/20/2026