TypeFinder is a .NET console application designed to help coding agents quickly locate types within a workspace. It leverages the Roslyn compiler APIs to provide fast, accurate, and comprehensive type discovery across multiple programming languages and file types.
This tool is specifically designed for integration with coding agents like Cursor, providing them with the ability to:
- Find exact locations of type definitions using Roslyn compiler APIs
- Discover all references to types throughout the codebase
- Search across multiple programming languages with fallback to file-based search
- Get contextual information about type usage with precise line numbers
- Filter results by file types and search criteria
- Understand type relationships and dependencies
The tool is located in the src/TypeFinder
directory. To use it, you need .NET 8.0 or later installed.
Use the provided installation script to publish and install the tool:
./install-typefinder.sh --install-dir ~/.local/bin
This will:
- Publish the TypeFinder tool (using Native AOT if dependencies are available)
- Create a symlink named
find-type
in the specified directory - Make the tool available for use
For comprehensive .NET installation instructions optimized for AI development assistants, see: https://raw.githubusercontent.com/richlander/dotnet-install-for-agents/main/README.md
⚠️ IMPORTANT: Git History WarningDO NOT commit these downloaded files to git history! The installation scripts may download files that should never be added to version control:
_temp/
directory (contains scripts and installers when downloaded to project root)~/.dotnet/
directory (SDK installation location)Always ensure these files/directories are in your .gitignore or excluded from commits. This is critical to avoid polluting project repositories.
Add these patterns to .gitignore when working in project repositories:
# .NET installation scripts and tools (DO NOT COMMIT) _temp/ # .NET SDK installation directory (if installed locally) .dotnet/
Quick install:
curl -sSL https://raw.githubusercontent.com/richlander/dotnet-install-for-agents/main/scripts/setup-dotnet.sh | bash
find-type <workspace-path> <type-name> [options]
cd src/TypeFinder
dotnet run -- <workspace-path> <type-name>
-
Find a class named "User" in the workspace:
find-type . User
-
Find exact type definitions only:
find-type . "MyClass" --exact-match
-
Search only in C# and TypeScript files:
find-type . Controller --file-types .cs,.ts
-
Case-sensitive search:
find-type . "MyClass" --case-sensitive
-
Limit results to 10:
find-type . Service --max-results 10
-
Search in a specific workspace:
find-type /path/to/other/workspace User
-
Find all references to a type:
find-type . MyClass --include-references
Option | Description | Default |
---|---|---|
--exact-match |
Search for exact type name match (definitions only) | false |
--case-sensitive |
Use case-sensitive search | false |
--file-types |
Comma-separated list of file extensions to search | .cs,.ts,.js,.py,.java,.go,.rs,.php |
--max-results |
Maximum number of results to return | 50 |
--include-references |
Include type references (not just definitions) | false |
By default, TypeFinder searches in the following file types:
.cs
- C# files.ts
- TypeScript files.js
- JavaScript files.py
- Python files.java
- Java files.go
- Go files.rs
- Rust files.php
- PHP files
You can customize this list using the --file-types
option.
The tool provides structured output with the following information for each match:
File: /path/to/file.cs
Line: 42
Type: MyClass
Kind: class
Context: public class MyClass
>>> {
>>> private string _name;
>>> }
- File: Full path to the file containing the type
- Line: Line number where the type was found
- Type: The actual type name that was found
- Kind: Type of the match (class, interface, struct, enum, record, namespace, method, property, field, event, reference, or symbol)
- Context: Surrounding code context (2 lines before and after)
Coding agents can use this tool to:
- Locate type definitions when they need to understand the structure of a type
- Find all references to understand how types are used throughout the codebase
- Get contextual information to make better code suggestions
- Discover related types by searching for similar naming patterns
- Understand type relationships by analyzing dependencies and usage patterns
# Agent wants to find the User class definition
find-type . User --exact-match
# Agent wants to see all usages of a specific interface
find-type . IUserService --include-references
# Agent wants to find all controller classes
find-type . Controller --file-types .cs,.ts
# Agent wants to understand all references to a type
find-type . MyClass --include-references --max-results 100
cd src/TypeFinder
dotnet build
dotnet run -- <arguments>
To publish an app in the default mode, use dotnet publish
. That produces a release binary for the current machine:
dotnet publish -c Release -r linux-x64 --self-contained true
- Roslyn Integration: Uses Microsoft's Roslyn compiler APIs for accurate type analysis
- Multi-language Support: Searches across multiple programming languages with fallback to file-based search
- Comprehensive Discovery: Finds both type definitions and all references throughout the codebase
- Flexible Search: Exact match or partial match options with case sensitivity control
- Contextual Output: Shows surrounding code for better understanding
- Performance Optimized: Fast compilation-based searching with configurable limits
- Error Handling: Graceful handling of compilation errors and invalid files
- Configurable: Customizable file types and result limits
The tool handles various error conditions gracefully:
- Invalid workspace paths
- Permission denied errors when accessing files
- Unreadable or corrupted files
- Compilation errors in projects
- Invalid command line arguments
- The tool uses Roslyn compilation for accurate analysis, which may take longer for large projects
- Use
--file-types
to limit search scope for better performance - Use
--max-results
to limit output size - The tool falls back to file-based search if compilation fails
- The tool skips files it cannot read and continues with the search
This tool is designed to be simple and focused. If you need additional features, consider:
- Adding support for more file types
- Implementing more sophisticated type detection patterns
- Adding support for different output formats (JSON, XML, etc.)
- Implementing caching for large workspaces