Skip to content

Instantly share code, notes, and snippets.

@meghuizen
Created March 14, 2025 09:43
Show Gist options
  • Save meghuizen/6d5c216922d1c7477226b4f35b0fdaa3 to your computer and use it in GitHub Desktop.
Save meghuizen/6d5c216922d1c7477226b4f35b0fdaa3 to your computer and use it in GitHub Desktop.
Solution Indexer Project Requirements
Project Overview
Develop a high-performance C# command-line tool that indexes a .NET solution folder, analyzes its structure and dependencies, and generates a comprehensive prompt containing relevant information. The tool should scan project files, source code, and configuration files with minimal memory usage and maximum performance.
Core Requirements
Input & Output
Accept a directory path as the main command-line argument
Optional parameter for output file path (default: "solution-prompt.txt")
Support a --recursive flag for deep directory traversal
Generate a well-formatted Markdown document describing the solution
generate all the code in 1 program.cs
use namespace Source2LLM
Solution Structure Analysis
Detect .NET solution files (.sln and .slnx)
Support for multiple project types (C#, VB.NET, F#)
Capture the complete folder structure of the solution
Identify project SDK information for each project
Analyze project dependencies to build a dependency graph
Identify top-level entry point projects
Project Analysis
Parse project files (.csproj, .vbproj, .fsproj)
Extract information about:
Language (C#, VB.NET, F#)
Target framework
SDK type
Output type
NuGet package references
Project references
Detect special project types:
Azure Functions
Aspire AppHost and Service projects
Projects using ILMerge
Projects using Application Insights
Source Code Collection
Support for multiple source file types:
C# (.cs)
VB.NET (.vb)
F# (.fs, .fsx)
SQL (.sql)
Markdown (.md, .mdc)
Text files (.txt)
Custom rule files (.clinerules, .cursorrules)
Use the appropriate language highlighter for each file type
Limit the number of files per project to a configurable amount
Truncate large files to a reasonable size
Skip Entity Framework migration files
Skip binary files
Configuration & Data Source Analysis
Scan configuration files:
appsettings.json
appsettings.Development.json
appsettings.local.json
host.json
local.settings.json
Detect and categorize data sources without leaking sensitive information:
SQL Server/Azure SQL
PostgreSQL
MySQL/MariaDB
SQLite
Redis
Azure Storage
MongoDB/Cosmos DB
Elasticsearch
Neo4j
Vector databases (Qdrant, Pinecone, Milvus, Weaviate, Chroma)
Azure Functions bindings
Performance Requirements
Memory Optimization
Minimize memory allocations throughout the application
Use efficient stream reading techniques for file content
Process files in batches to reduce memory pressure
Detect and skip large files early
Use efficient collections like ConcurrentDictionary and ConcurrentBag where appropriate
Speed Optimization
Single-pass directory traversal to reduce I/O operations
Parallel processing with controlled degree of parallelism
Efficient early filtering of irrelevant files and directories
Use regex compilation and efficient pattern matching
Properly sized buffers for file I/O
Output Format
The generated prompt should include the following sections:
Solution Overview
Root directory
Solution files
Project Dependencies
Hierarchical project reference structure
Top-level entry point projects
Data Sources
Organized by type
Project association
Provider details
Relevant properties (no secrets)
Projects
Path information
Language and SDK
Framework and output type
Project references
Package references
Source file count
Folder Structure
Complete directory layout
Files in each directory
Source Code
Project-organized code samples
Properly syntax-highlighted
Reasonably truncated files
Technical Constraints
Target .NET 9
Minimize external dependencies
Focus on asynchronous I/O operations
Robust error handling without crashing
Support for large solutions with many projects
Implementation Notes
Use class-based models for structured information
Implement proper regular expressions for parsing
Apply clean coding practices with minimal duplication
Make constants configurable at the top of the code
Include detailed comments for complex logic
This tool should generate a comprehensive snapshot of a .NET solution that could be fed to an LLM to provide deep context about a project's architecture and dependencies, facilitating better understanding of existing codebases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment