Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors and hardens several core behaviors across ProjGraph: SCC (Tarjan) detection is made iterative to avoid stack overflows, dependency depth stats are updated to use nulls when cycles exist, parsing/error handling is improved (notably for .slnx), and multiple utilities are adjusted for determinism and robustness.
Changes:
- Refactor Tarjan SCC algorithm to an iterative implementation and add deep-graph tests.
- Update dependency depth stats to use nullable values when cycles are present, and extend stats-related tests.
- Improve parsing/utilities (e.g.,
.slnxmalformed XML errors, deterministic type discovery, EF fluent parsing, MCP JSON options) and adjust console rendering approach.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/ProjGraph.Tests.Unit.ProjectGraph/ComputeStatsUseCaseTests.cs | Updates cycle-depth expectations to nulls and adds edge-case coverage (self-ref, deep chain, Unicode). |
| tests/ProjGraph.Tests.Unit.ProjectGraph/BuildGraphUseCaseTests.cs | Adds coverage for self-referencing project dependencies. |
| tests/ProjGraph.Tests.Unit.EntityFramework/FluentApiParsingUtilitiesTests.cs | Adds cases ensuring parentheses inside string literals don’t break UsingEntity block detection. |
| tests/ProjGraph.Tests.Unit.EntityFramework/EfAnalysisAdvancedTests.cs | Adds advanced EF analysis coverage (keyless entities, converters, owned types, TPT). |
| tests/ProjGraph.Tests.Unit.Core/Parsers/SlnxParserTests.cs | Expects ParsingException for malformed XML and adds BOM handling test. |
| tests/ProjGraph.Tests.Unit.Core/Parsers/ProjectParserTests.cs | Adds parsing coverage for BOM files, conditional item groups, and version range syntax. |
| tests/ProjGraph.Tests.Unit.Core/NullOutputConsoleTests.cs | Adds test ensuring empty selection choices throw a clear exception. |
| tests/ProjGraph.Tests.Unit.Core/Algorithms/TarjanSccAlgorithmTests.cs | Adds deep-chain test to guard against StackOverflow regressions. |
| tests/ProjGraph.Tests.Unit.ClassDiagram/TypeAnalyzerTests.cs | Adds broader Roslyn type-analysis cases (nested, generics/constraints, static, defaults, etc.). |
| src/ProjGraph.Mcp/ProjGraphTools.cs | Uses explicit JsonSerializerOptions (camelCase) when serializing stats. |
| src/ProjGraph.Lib.ProjectGraph/DependencyInjection.cs | Changes renderer DI lifetimes from transient to singleton. |
| src/ProjGraph.Lib.ProjectGraph/Application/UseCases/ComputeStatsUseCase.cs | Switches cycle depth stats sentinel values to nulls when cycles are detected. |
| src/ProjGraph.Lib.EntityFramework/Infrastructure/FluentApiParsingUtilities.cs | Strips string literals before counting parentheses for UsingEntity detection. |
| src/ProjGraph.Lib.Core/Parsers/SlnxParser.cs | Wraps malformed .slnx XML errors into ParsingException. |
| src/ProjGraph.Lib.Core/Infrastructure/SpectreOutputConsole.cs | Introduces static Write(IRenderable) helper for Spectre renderables. |
| src/ProjGraph.Lib.Core/Abstractions/NullOutputConsole.cs | Removes renderable write and throws on empty selection prompts. |
| src/ProjGraph.Lib.Core/Abstractions/IOutputConsole.cs | Removes Write(IRenderable) from the abstraction. |
| src/ProjGraph.Lib.ClassDiagram/Infrastructure/WorkspaceTypeDiscovery.cs | Collects all matches and deterministically selects a sorted first match. |
| src/ProjGraph.Core/Models/SolutionStats.cs | Makes dependency depth stats nullable and updates related documentation. |
| src/ProjGraph.Cli/Commands/StatsCommand.cs | Switches renderable output to SpectreOutputConsole.Write(...). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
src/ProjGraph.Lib.ProjectGraph/Application/UseCases/ComputeStatsUseCase.cs
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and fixes across the codebase, including a major refactor of the Tarjan's algorithm implementation to make it iterative, enhancements to dependency depth statistics handling, improved error handling for
.slnxparsing, and better deterministic type discovery. Additionally, it updates dependency injection lifetimes for renderers and improves string parsing in Entity Framework utilities. Below are the most important changes grouped by theme:Algorithms and Statistics
TarjanSccAlgorithm.csto use an explicit stack for iterative traversal, replacing recursion. This preventsStackOverflowExceptionon deep dependency chains and improves reliability for large graphs. [1] [2]DependencyDepthStatsto use nullable values (double?,int?) when cycles are detected, rather than sentinel values (-1), and updated logic inComputeStatsUseCase.csto support this. [1] [2]Console Output and Infrastructure
Write(IRenderable)method fromIOutputConsoleand its implementations, and replaced usages with the staticSpectreOutputConsole.Write(IRenderable)method for rendering Spectre.Console objects. [1] [2] [3] [4] [5]NullOutputConsoleto throw an exception if no choices are available when prompting for selection, making error handling more robust.Parsing and Error Handling
SlnxParserso that malformed XML in.slnxfiles throws aParsingException, improving reliability and debugging. [1] [2]Dependency Injection and Service Lifetimes
DependencyInjection.csfrom transient to singleton, clarifying that all renderers are stateless and improving resource usage.Workspace and Entity Framework Utilities
WorkspaceTypeDiscovery.csto collect all matching files and return the deterministically sorted first match, ensuring consistent results when multiple files define the same type. [1] [2] [3]FluentApiParsingUtilitiesto strip string literals before counting parentheses, preventing errors in block detection logic for Entity Framework Fluent API parsing. [1] [2]Other notable changes include setting consistent JSON serialization options in
ProjGraphTools.csfor camelCase property naming. [1] [2]