Skip to content

C# Header Extractor: A Roslyn-based tool to convert source code into compact, AI-optimized headers for massive token savings.

License

Notifications You must be signed in to change notification settings

Holginger/hsHeaderGen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hsHeaderGen

A Roslyn-powered C# Header Extractor for AI Context Optimization

hsHeaderGen is a lightweight command-line tool designed to bridge the gap between large C# codebases and AI context windows (like Gemini, ChatGPT, or Claude). It extracts the "architectural skeleton" of your code, providing the AI with all the necessary information while saving up to 90% of tokens.

🚀 Why hsHeaderGen?

When working with LLMs, feeding entire source files often wastes precious tokens on boilerplate and implementation details. hsHeaderGen solves this by:

  • Stripping method bodies: Keeping only the signatures.
  • Filtering by visibility: Focusing on public and protected members.
  • Providing metadata: Adding estimated token counts and file statistics.

✨ Features

  • 🧠 Roslyn-based: Uses the official Microsoft C# compiler platform for precise syntax analysis.
  • AI-Optimized: Generates .h.ai files (Header Files for AI) that are easy for LLMs to parse.
  • 📂 Flexible Crawling: Processes entire solutions while maintaining directory structures.
  • 🛠️ Developer Friendly: Specifically designed to be used as an "External Tool" within Visual Studio.

🛠 Installation & Setup

1. Build & Initial Run

  • Publish the project as a Single File executable.
  • Copy the .exe to your preferred permanent location (e.g., C:\Tools\).
  • Run the tool once manually from its new location.

2. Self-Registration

On its first run, hsHeaderGen automatically adds its location to your User Path Environment Variable.

  • The tool will then exit.
  • From now on, you can call hsHeaderGen from any command prompt or terminal without specifying the full path. (Note: You may need to restart your terminal or Visual Studio to refresh the environment variables).

3. General Usage

Once registered, simply open a terminal in your project's root folder and type: bash> hsHeaderGen Options: hsHeaderGen . : Extracts public/protected members (standard). hsHeaderGen . -p : Includes private members for deeper AI analysis. hsHeaderGen [Path] : Processes a specific directory instead of the current one.

4. **Visual Studio Setup (option):

Go to Tools -> External Tools... Title: hsHeaderGen Command: C:\Tools\hsHeaderGen.exe Arguments: "$(SolutionDir)" Initial Directory: $(SolutionDir) Check: "Use Output window"

📝 Usage

Once integrated, simply run the tool from the Visual Studio Tools menu. It will:

  1. Scan your current solution.
  2. Extract headers for all relevant types.
  3. Save them to a dedicated output folder and copy the summary to the clipboard.
  4. Provide a summary in the Visual Studio Output window.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤖 AI Statement

This tool was designed by a craftsman and developed with AI assistance (Gemini). It serves as a prime example of human-AI collaboration to optimize modern software development workflows.

About

C# Header Extractor: A Roslyn-based tool to convert source code into compact, AI-optimized headers for massive token savings.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages