Skip to content

Add directory class diagram scanning#42

Merged
HandyS11 merged 2 commits intodevelopfrom
009-directory-class-diagram
Feb 24, 2026
Merged

Add directory class diagram scanning#42
HandyS11 merged 2 commits intodevelopfrom
009-directory-class-diagram

Conversation

@HandyS11
Copy link
Copy Markdown
Owner

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

  • Added recursive directory scanning for .cs files, enabling generation of a single combined class diagram for all types in a directory. Standard folders like .git, bin, obj, and node_modules are automatically excluded, and a warning is issued if more than 50 files are found. [1] [2] [3]
  • CLI and documentation updated to show usage: projgraph classdiagram ./Models/ generates a combined diagram for all classes in the directory. [1] [2]
  • New sample output file simple-hierarchy-folder.mmd demonstrates directory scan results.

Specification and Planning Artifacts

  • Added specification checklist, contract, data model, and implementation plan for the directory scanning feature, ensuring requirements are clear and testable. [1] [2] [3] [4]

Sample Regeneration Script Improvements

  • Updated regenerate-samples.ps1 to support directory scanning and output parameter, simplifying file writing and adding a new sample for directory scan. [1] [2]

Technology References

  • Updated technology references and recent changes to include Roslyn for directory scanning and memory analysis. [1] [2]

Sample Cleanup

Copilot AI review requested due to automatic review settings February 24, 2026 15:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 DiscoverCsFilesUseCase and AnalyzeDirectoryUseCase
  • Extended IClassAnalysisService with AnalyzeDirectoryAsync method
  • 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_ShouldLimitRelationshipDepth suggests it explicitly tests depth=1, but the test now relies on the default MaxDepth value (which happens to be 1). Consider either explicitly passing MaxDepth: 1 to make the test intention clear, or renaming the test to GetClassDiagram_WithDefaultDepth_ShouldLimitRelationshipDepth to accurately reflect what is being tested.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@HandyS11 HandyS11 merged commit 99f23a9 into develop Feb 24, 2026
9 checks passed
@HandyS11 HandyS11 deleted the 009-directory-class-diagram branch February 24, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants