Claude Code Plugins

Community-maintained marketplace

Feedback

type-collision-detector

@CyberdineDevelopment/claude-tools
0
0

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)

Install Skill

1Download skill
2Enable skills in Claude

Open claude.ai/settings/capabilities and find the "Skills" section

3Upload to Claude

Click "Upload skill" and select the downloaded ZIP file

Note: Please verify skill by going through its instructions before using it.

SKILL.md

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 Product collide 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

  1. Scans your solution for all type definitions
  2. Groups types by name (ignoring namespace)
  3. Identifies collisions - Same type name in different namespaces
  4. Excludes external packages - Only checks YOUR code
  5. 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:

  1. Ensure server is running (start if needed)
  2. Load solution into workspace if not already loaded
  3. Call DetectCollisions endpoint
  4. Parse and present results showing:
    • All colliding type names
    • Their locations and namespaces
    • Suggestions for resolution
  5. 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:

  1. Suffix DTOs:

    • ProductDto
    • ProductRequest
    • ProductResponse
  2. Suffix ViewModels:

    • ProductViewModel
  3. Qualify by purpose:

    • ProductEntity (domain)
    • ProductModel (API)
  4. Use generic interfaces once:

    • Single IRepository<T> instead of multiple IRepository

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:

  1. Scan all .cs files in solution
  2. Build type registry
  3. Find duplicates
  4. 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