Skip to content

Conversation

@HandyS11
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings February 10, 2026 15:35
Copy link
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

Adds richer/cleaner visualize output options by moving console renderers into the ProjectGraph library, improving Mermaid output determinism, and updating CLI behavior/tests accordingly.

Changes:

  • Add new flat and tree graph renderers in ProjGraph.Lib.ProjectGraph.Rendering and select renderer by --format.
  • Improve Mermaid output with optional title front-matter and deterministic ordering for projects/dependencies.
  • Update CLI defaults/examples and adjust integration/unit tests for the new formats and default behavior.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
tests/ProjGraph.Tests.Unit.ProjectGraph/MermaidGraphRendererTests.cs Adds assertions for Mermaid title front-matter and ordering.
tests/ProjGraph.Tests.Integration.Cli/VisualizeCommandTests.cs Updates format-related tests and changes default format expectation to Mermaid.
src/ProjGraph.Lib.ProjectGraph/Rendering/TreeGraphRenderer.cs New Spectre.Console-based hierarchical tree renderer returning a string.
src/ProjGraph.Lib.ProjectGraph/Rendering/FlatGraphRenderer.cs New Spectre.Console-based flat list renderer returning a string.
src/ProjGraph.Lib.ProjectGraph/Rendering/SolutionGraphRendererBase.cs New shared base for Spectre.Console renderers (writer/console, cycle helpers).
src/ProjGraph.Lib.ProjectGraph/Rendering/MermaidGraphRenderer.cs Adds title front-matter and sorts projects/dependencies by name.
src/ProjGraph.Lib.ProjectGraph/DependencyInjection.cs Registers multiple renderers and exposes them via IEnumerable<IDiagramRenderer<SolutionGraph>>.
src/ProjGraph.Cli/Commands/VisualizeCommand.cs Switches to renderer selection by format and changes default format to Mermaid.
src/ProjGraph.Cli/Program.cs Updates CLI examples (visualize/tree example; classdiagram depth example).
src/ProjGraph.Cli/Rendering/TreeRenderer.cs Removes old CLI-only static renderer (moved into library as instance renderers).

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

Comment on lines +43 to +51
var sortedDependencies = graph.Dependencies
.Select(d => new
{
sb.AppendLine($" {SanitizeId(source.Name)} --> {SanitizeId(target.Name)}");
}
Source = graph.Projects.FirstOrDefault(p => p.Id == d.SourceId),
Target = graph.Projects.FirstOrDefault(p => p.Id == d.TargetId)
})
.Where(d => d.Source != null && d.Target != null)
.OrderBy(d => d.Source!.Name)
.ThenBy(d => d.Target!.Name);
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Dependency sorting currently does a graph.Projects.FirstOrDefault(...) lookup for every dependency, which is O(E*V) and can become expensive on large solutions. Consider building a Dictionary<Guid, Project> once (Id->Project) and resolving Source/Target via dictionary lookups before ordering.

Copilot uses AI. Check for mistakes.
Comment on lines +85 to +90
var dependencies = graph.Dependencies
.Where(d => d.SourceId == project.Id)
.Select(d => graph.Projects.FirstOrDefault(p => p.Id == d.TargetId))
.Where(p => p != null)
.OrderBy(p => p!.Name)
.ToList();
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

RenderDependencies resolves dependency projects via graph.Projects.FirstOrDefault(...) for each edge, which is O(E*V) overall. Consider precomputing an Id->Project dictionary (and optionally per-project dependency lists) once per Render() to avoid repeated linear scans.

Copilot uses AI. Check for mistakes.
Comment on lines +31 to 32
foreach (var project in graph.Projects.OrderBy(p => p.Name))
{
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Project/dependency ordering uses the default string comparer (culture-sensitive). Since the output order is now asserted in tests and is meant to be deterministic, consider ordering with a specific comparer (e.g., StringComparer.Ordinal) to avoid locale-dependent differences across environments.

Copilot uses AI. Check for mistakes.
@HandyS11 HandyS11 merged commit 4a3232e into develop Feb 10, 2026
2 checks passed
@HandyS11 HandyS11 deleted the feature/improve-visualize-graph branch February 10, 2026 16:03
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.

1 participant