Conversation
…nges for 009-directory-class-diagram
…and cross-file analysis
There was a problem hiding this comment.
Pull request overview
This pull request adds recursive directory scanning support to the class diagram generation feature in ProjGraph. Users can now provide a directory path instead of a single .cs file to generate a combined Mermaid class diagram of all types found in that directory and its subdirectories. The implementation automatically excludes standard artifact folders (bin, obj, .git, node_modules), creates a single Roslyn compilation for cross-file analysis, and warns users when scanning more than 50 files.
Changes:
- Added directory scanning infrastructure with
DiscoverCsFilesUseCaseandAnalyzeDirectoryUseCase - Extended
IClassAnalysisServicewithAnalyzeDirectoryAsyncmethod - Updated CLI and MCP server to accept directory paths in addition to file paths
- Added comprehensive test coverage including unit, integration, and contract tests
- Created detailed specification artifacts and updated documentation
Reviewed changes
Copilot reviewed 45 out of 45 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/ProjGraph.Lib.Core/Abstractions/IFileSystem.cs |
Added DirectoryExists, GetDirectories, and GetFiles methods to support directory traversal |
src/ProjGraph.Lib.Core/Infrastructure/PhysicalFileSystem.cs |
Implemented new IFileSystem methods with proper documentation |
src/ProjGraph.Lib.Core/Infrastructure/DirectoryFilters.cs |
Refactored to expose constants (Bin, Obj, Git, NodeModules, CSharpExtension) for reuse |
src/ProjGraph.Lib.Core/Infrastructure/WorkspaceRootResolver.cs |
Updated to use DirectoryFilters.Git constant |
src/ProjGraph.Lib.ClassDiagram/Application/UseCases/DiscoverCsFilesUseCase.cs |
New use case implementing recursive directory scanning with exclusion logic |
src/ProjGraph.Lib.ClassDiagram/Application/UseCases/AnalyzeDirectoryUseCase.cs |
New use case orchestrating multi-file analysis with unified Roslyn compilation |
src/ProjGraph.Lib.ClassDiagram/Application/IClassAnalysisService.cs |
Added AnalyzeDirectoryAsync method signature |
src/ProjGraph.Lib.ClassDiagram/Application/ClassAnalysisService.cs |
Implemented directory analysis delegation |
src/ProjGraph.Lib.ClassDiagram/DependencyInjection.cs |
Registered new use cases in DI container |
src/ProjGraph.Lib.ClassDiagram/Rendering/MermaidClassDiagramRenderer.cs |
Minor refactoring of AppendLine usage |
src/ProjGraph.Cli/Commands/ClassDiagramCommand.cs |
Updated validation and execution to handle both files and directories with 50-file warning |
src/ProjGraph.Mcp/Program.cs |
Updated GetClassDiagramAsync to support directories with warning markup for large sets |
tests/ProjGraph.Tests.Unit.ClassDiagram/DiscoverCsFilesUseCaseTests.cs |
Unit tests for directory discovery logic |
tests/ProjGraph.Tests.Unit.ClassDiagram/AnalyzeDirectoryUseCaseTests.cs |
Unit tests for directory analysis including edge cases |
tests/ProjGraph.Tests.Integration.Cli/ClassDiagramCommandTests.cs |
Integration tests for CLI directory scanning |
tests/ProjGraph.Tests.Integration.Mcp/McpClassDiagramTests.cs |
Integration test for MCP directory scanning |
tests/ProjGraph.Tests.Contract/McpClassDiagramTests.cs |
Updated contract test to verify "directory" in description |
samples/regenerate-samples.ps1 |
Updated to use --output parameter instead of capturing stdout |
samples/classdiagram/simple-hierarchy/simple-hierarchy-folder.mmd |
New sample output demonstrating directory scan |
specs/009-directory-class-diagram/* |
Complete specification artifacts (spec, plan, research, tasks, contracts, checklist) |
| Documentation files | Updated README, CLI README, MCP README, ARCHITECTURE.md with directory scanning examples |
Comments suppressed due to low confidence (1)
tests/ProjGraph.Tests.Integration.Mcp/McpClassDiagramTests.cs:270
- The test method name
GetClassDiagram_WithDepth1_ShouldLimitRelationshipDepthsuggests it explicitly tests depth=1, but the test now relies on the default MaxDepth value (which happens to be 1). Consider either explicitly passingMaxDepth: 1to make the test intention clear, or renaming the test toGetClassDiagram_WithDefaultDepth_ShouldLimitRelationshipDepthto accurately reflect what is being tested.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request introduces support for recursive directory scanning for class diagram generation in ProjGraph. Users can now generate a combined Mermaid class diagram for all classes in a directory, with automatic exclusion of standard folders and a warning for large sets. The update is thoroughly documented and includes new sample outputs, specification artifacts, and improvements to the sample regeneration script.
Feature: Directory Scanning for Class Diagrams
.csfiles, enabling generation of a single combined class diagram for all types in a directory. Standard folders like.git,bin,obj, andnode_modulesare automatically excluded, and a warning is issued if more than 50 files are found. [1] [2] [3]projgraph classdiagram ./Models/generates a combined diagram for all classes in the directory. [1] [2]simple-hierarchy-folder.mmddemonstrates directory scan results.Specification and Planning Artifacts
Sample Regeneration Script Improvements
regenerate-samples.ps1to support directory scanning and output parameter, simplifying file writing and adding a new sample for directory scan. [1] [2]Technology References
Sample Cleanup