Andy.CodeAnalyzer
2025.7.21-rc.6
dotnet add package Andy.CodeAnalyzer --version 2025.7.21-rc.6
NuGet\Install-Package Andy.CodeAnalyzer -Version 2025.7.21-rc.6
<PackageReference Include="Andy.CodeAnalyzer" Version="2025.7.21-rc.6" />
<PackageVersion Include="Andy.CodeAnalyzer" Version="2025.7.21-rc.6" />
<PackageReference Include="Andy.CodeAnalyzer" />
paket add Andy.CodeAnalyzer --version 2025.7.21-rc.6
#r "nuget: Andy.CodeAnalyzer, 2025.7.21-rc.6"
#:package Andy.CodeAnalyzer@2025.7.21-rc.6
#addin nuget:?package=Andy.CodeAnalyzer&version=2025.7.21-rc.6&prerelease
#tool nuget:?package=Andy.CodeAnalyzer&version=2025.7.21-rc.6&prerelease
Andy.CodeAnalyzer
A code analysis library for the Andy AI assistant that provides real-time code indexing, searching, and context understanding capabilities.
Features
- Multi-Language Support: Built-in analyzers for C# and Python with extensible architecture for additional languages
- Real-Time Indexing: Automatic file watching and incremental indexing of code changes
- Advanced Search: Full-text and symbol-based search with support for regex patterns
- Code Structure Analysis: Extracts classes, methods, properties, and other symbols from source files
- Context Awareness: Provides code context including parent symbols, nearby symbols, and imports
- SQLite Storage: Efficient local storage using Entity Framework Core with SQLite
- Async Operations: Fully asynchronous API for non-blocking operations
- Event-Driven: File change notifications and indexing progress events
Installation
Add the Andy.CodeAnalyzer package to your .NET project:
dotnet add package Andy.CodeAnalyzer
Quick Start
using Andy.CodeAnalyzer.Extensions;
using Microsoft.Extensions.DependencyInjection;
// Configure services
var services = new ServiceCollection();
services.AddCodeAnalyzer(options =>
{
options.DatabaseConnectionString = "Data Source=codeanalyzer.db";
options.EnableFileWatching = true;
options.MaxConcurrentIndexing = 4;
});
// Build service provider
var serviceProvider = services.BuildServiceProvider();
// Get the analyzer service
var analyzer = serviceProvider.GetRequiredService<ICodeAnalyzerService>();
// Subscribe to progress events
analyzer.IndexingProgress += (sender, e) =>
{
Console.WriteLine($"Indexing progress: {e.ProcessedFiles}/{e.TotalFiles} files");
if (e.CurrentFile != null)
{
Console.WriteLine($"Processing: {e.CurrentFile}");
}
if (e.IsComplete)
{
Console.WriteLine("Indexing complete!");
}
};
// Initialize for a workspace
await analyzer.InitializeAsync("/path/to/your/project");
// Search for symbols
var symbols = await analyzer.SearchSymbolsAsync("MyClass", new SymbolFilter
{
Kind = SymbolKind.Class
});
// Get file structure
var structure = await analyzer.GetFileStructureAsync("/path/to/file.cs");
// Search text
var results = await analyzer.SearchTextAsync("TODO", new SearchOptions
{
UseRegex = false,
CaseSensitive = false
});
Architecture
Core Components
Language Analyzers: Pluggable analyzers for different programming languages
CSharpAnalyzer
: Uses Roslyn for C# code analysisPythonAnalyzer
: Python code analysis support- Extensible via
ILanguageAnalyzer
interface
Services:
CodeAnalyzerService
: Main orchestrator serviceIndexingService
: Handles file indexing and database operations with progress reportingSearchService
: Provides search functionalityContextProviderService
: Generates code context informationFileWatcherService
: Monitors file system changes
Storage:
- Entity Framework Core with SQLite
- Stores file metadata, symbols, and dependencies
- Optimized for fast retrieval and search operations
Data Models
- CodeStructure: Represents analyzed file structure with symbols, imports, and exports
- Symbol: Code elements (classes, methods, properties, etc.) with location and metadata
- SearchResult: Search match results with context
- FileChangeEvent: File system change notifications
Configuration
services.AddCodeAnalyzer(options =>
{
// Database connection string
options.DatabaseConnectionString = "Data Source=codeanalyzer.db";
// Enable/disable file watching
options.EnableFileWatching = true;
// Enable/disable initial indexing on startup
options.IndexOnStartup = true;
// File patterns to include/exclude
options.IncludePatterns = new[] { "**/*.cs", "**/*.py" };
options.ExcludePatterns = new[] { "**/bin/**", "**/obj/**", "**/node_modules/**" };
// Performance tuning
options.MaxConcurrentIndexing = 4;
options.IndexingBatchSize = 100;
options.CacheSize = 1000;
});
API Reference
For detailed API documentation, see API Reference.
ICodeAnalyzerService
The main service interface providing:
InitializeAsync(workspacePath)
: Initialize analyzer for a workspaceGetFileStructureAsync(filePath)
: Get analyzed structure of a fileSearchTextAsync(query, options)
: Search for text in codebaseSearchSymbolsAsync(query, filter)
: Search for symbolsFindReferencesAsync(symbolName)
: Find all references to a symbolGetContextForLocationAsync(file, line, column)
: Get code context at locationGetRelatedFilesAsync(filePath)
: Find related filesGetStatisticsAsync()
: Get analyzer statistics
Events
FileChanged
Raised when a file is added, modified, or deleted in the watched workspace.
analyzer.FileChanged += (sender, e) =>
{
Console.WriteLine($"File {e.Change.ChangeType}: {e.Change.FilePath}");
};
IndexingProgress
Reports detailed progress during indexing operations, including:
- Total number of files to be indexed
- Number of files processed so far
- Current file being processed
- Completion status
analyzer.IndexingProgress += (sender, e) =>
{
var percentage = (e.ProcessedFiles * 100.0) / e.TotalFiles;
Console.WriteLine($"Progress: {percentage:F1}% ({e.ProcessedFiles}/{e.TotalFiles})");
if (e.CurrentFile != null)
{
Console.WriteLine($"Indexing: {Path.GetFileName(e.CurrentFile)}");
}
if (e.IsComplete)
{
Console.WriteLine("Indexing completed successfully!");
}
};
Requirements
- .NET 8.0 or later
- SQLite support
- Write access for database file
Dependencies
- Microsoft.CodeAnalysis.CSharp (4.12.0) - For C# code analysis
- Microsoft.EntityFrameworkCore.Sqlite (8.0.x) - For data storage
- Microsoft.Extensions.DependencyInjection (8.0.x) - For dependency injection
- System.Threading.Channels (8.0.x) - For async operations
Documentation
- API Reference - Detailed API documentation
- C# Analyzer - How the C# analyzer works
- Python Analyzer - How the Python analyzer works
- Examples - Sample applications demonstrating features
Contributing
Contributions are welcome! To add support for a new language:
- Implement the
ILanguageAnalyzer
interface - Register your analyzer in
ServiceCollectionExtensions
- Add appropriate tests
License
This project is part of the Andy AI assistant and follows the same license terms.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net8.0
- Microsoft.CodeAnalysis.CSharp (>= 4.8.0)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 4.8.0)
- Microsoft.Data.Sqlite (>= 8.0.0)
- Microsoft.EntityFrameworkCore.Sqlite (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
- System.Threading.Channels (>= 8.0.0)
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 |
---|---|---|
2025.7.21-rc.6 | 214 | 7/21/2025 |
2025.7.21-rc.4 | 215 | 7/21/2025 |
2025.7.15-rc.2 | 109 | 7/15/2025 |