| name | type-collision-detector |
| description | Find duplicate type names within your solution (same name in different namespaces). Use before creating new types to avoid naming conflicts. Only checks your code, not external packages. (project, gitignored) |
Type Collision Detector Skill
This skill detects when you have multiple types with the same name in different namespaces within your own codebase.
Tool Location: D:\FractalDataworks\RoslynTools\src\RoslynTools.TypeCollisionDetector
When to Use This Skill
- Before creating a new type - "Will
Productcollide with anything?" - "Do I have any duplicate type names?"
- "Are there multiple classes named
Result?" - When experiencing ambiguous reference errors
- During code review to catch naming issues
- When merging branches that may have added similar types
API Endpoint
GET /analysis/collisions
Request:
{
"scope": "solution"
}
Response:
{
"isSuccess": true,
"data": {
"collisions": [
{
"typeName": "Product",
"occurrences": [
{
"namespace": "MyApp.Domain.Models",
"filePath": "src/Domain/Models/Product.cs",
"lineNumber": 10,
"kind": "class"
},
{
"namespace": "MyApp.API.DTOs",
"filePath": "src/API/DTOs/Product.cs",
"lineNumber": 8,
"kind": "class"
}
],
"suggestion": "Rename DTO to 'ProductDto' or 'ProductResponse'"
}
]
}
}
Scope Options:
"solution"- Check entire solution"project"- Check specific project only
What This Skill Does
- Scans your solution for all type definitions
- Groups types by name (ignoring namespace)
- Identifies collisions - Same type name in different namespaces
- Excludes external packages - Only checks YOUR code
- Reports severity:
- ERROR: Exact same name, different namespaces
- WARNING: Similar names (case differences, pluralization)
Why This Matters
// File: src/Domain/Models/Product.cs
namespace MyApp.Domain.Models
{
public class Product { } // Your domain entity
}
// File: src/API/DTOs/Product.cs
namespace MyApp.API.DTOs
{
public class Product { } // Your DTO
}
// This causes problems:
using MyApp.Domain.Models;
using MyApp.API.DTOs;
var product = new Product(); // ERROR: Ambiguous reference!
Output Format
=== TYPE COLLISION REPORT ===
Status: ⚠ COLLISIONS FOUND
ERRORS (Must Fix):
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1. "Product" (2 definitions)
✗ MyApp.Domain.Models.Product
File: src/Domain/Models/Product.cs:10
Type: class
✗ MyApp.API.DTOs.Product
File: src/API/DTOs/Product.cs:8
Type: class
SUGGESTION: Rename DTO to "ProductDto" or "ProductResponse"
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
SUMMARY:
Total Types Scanned: 145
Collisions Found: 1 error
Recommendation: Fix errors before creating new types
How It Works
1. Start the Server
dotnet run --project D:\FractalDataworks\RoslynTools\src\CyberdineDevelopment.RoslynTools.Server
2. Load Solution
using CyberdineDevelopment.RoslynTools.Client;
var client = new RoslynWorkspaceClient("http://localhost:5000");
await client.LoadSolution(@"D:\MyProject\MyProject.sln");
3. Detect Collisions
// Check for type collisions
var result = await client.DetectCollisions(scope: "solution");
if (result.IsSuccess && result.Data.Collisions.Any())
{
Console.WriteLine($"Found {result.Data.Collisions.Count} collisions");
foreach (var collision in result.Data.Collisions)
{
Console.WriteLine($"\nType: {collision.TypeName}");
Console.WriteLine($" Occurrences: {collision.Occurrences.Count}");
foreach (var occurrence in collision.Occurrences)
{
Console.WriteLine($" {occurrence.Namespace}.{collision.TypeName}");
Console.WriteLine($" File: {occurrence.FilePath}:{occurrence.LineNumber}");
}
if (!string.IsNullOrEmpty(collision.Suggestion))
{
Console.WriteLine($" Suggestion: {collision.Suggestion}");
}
}
}
else
{
Console.WriteLine("No type collisions found!");
}
Workflow
When this skill is invoked:
- Ensure server is running (start if needed)
- Load solution into workspace if not already loaded
- Call DetectCollisions endpoint
- Parse and present results showing:
- All colliding type names
- Their locations and namespaces
- Suggestions for resolution
- Recommend fixes
Semantic Analysis Benefits
Using the Server API provides significant advantages:
- Solution-Wide Analysis: Check all projects in the solution at once
- Accurate Type Resolution: Uses ISymbol to definitively identify types
- Cross-Project Detection: Find collisions across project boundaries
- Namespace-Aware: Understands namespace scope and accessibility
- Fast In-Memory: No file system scanning required
- Live Detection: Can check before committing changes to disk
Common Collision Patterns
Domain Model vs DTO:
Domain.Models.Product vs API.DTOs.Product
→ Suggest: ProductDto, ProductResponse
Result types:
Core.Result vs Services.ServiceResult vs API.ApiResult
→ Suggest: Use IGenericResult<T> everywhere
Suggested Naming Conventions
To avoid collisions:
Suffix DTOs:
ProductDtoProductRequestProductResponse
Suffix ViewModels:
ProductViewModel
Qualify by purpose:
ProductEntity(domain)ProductModel(API)
Use generic interfaces once:
- Single
IRepository<T>instead of multipleIRepository
- Single
Integration with Other Skills
Workflow before creating a new type:
1. type-collision-detector → Check if name exists
2. type-finder "MyNewType" → Verify it's unique
3. namespace-explorer → Check target namespace conventions
4. Create type following conventions
5. build → Verify no ambiguous references
When collision found:
1. type-collision-detector → Find all definitions
2. refactor → Rename one or more types
3. build → Verify build succeeds
4. Run again to confirm collision resolved
Example Usage
User asks:
- "Check for type collisions"
- "Can I name my new class
Result?" - "Why am I getting 'ambiguous reference' errors?"
Skill will:
- Scan all .cs files in solution
- Build type registry
- Find duplicates
- Generate report with suggestions
Notes
- Uses Roslyn Workspace API with semantic model
- Runs quickly (in-memory, no file system scanning)
- Can be run pre-commit (via git hook)
- Fully language-aware (understands C# type system)
- Handles partial classes correctly (same name OK if same namespace)
- Cross-project collision detection
- Server maintains workspace state between checks