Files
sql-utilities/src/Strata.SqlTools.Markdown/Snowflake/SqlStatementGenerator.cs
T
Thom LambandClaude Opus 4.7 423108a7dc
SonarQube Analysis / sonarqube (pull_request) Successful in 4m22s
chore(sonar)!: mark Markdown generator classes as 'public static class' (S1118)
After the CA1822 cascade in #15 left every method on the eight
Markdown generator classes static, the classes themselves were
instantiable shells that consumers couldn't usefully `new`. This
commit flips the `class` modifier to `static class` on all eight:

- `Markdown.SqlServer.QueryBreakdownGenerator`
- `Markdown.SqlServer.SqlStatementGenerator`
- `Markdown.LinqToSql.QueryBreakdownGenerator`
- `Markdown.LinqToSql.SqlStatementGenerator`
- `Markdown.PostgreSql.QueryBreakdownGenerator`
- `Markdown.PostgreSql.SqlStatementGenerator`
- `Markdown.Snowflake.QueryBreakdownGenerator`
- `Markdown.Snowflake.SqlStatementGenerator`

Test fixtures drop the now-meaningless `_generator = new …()` field
and `[SetUp]` (kept the existing Setup body where unrelated state was
also initialized — `QueryMarkdownGenerationTests` and
`LinqToSql.QueryBreakdownGeneratorTests`).

BREAKING CHANGE: External NuGet consumers can no longer write
`new Markdown.Snowflake.SqlStatementGenerator()` (or any of the other
seven classes above) — the type is now a static container and may only
be referenced by name, e.g.
`Markdown.Snowflake.SqlStatementGenerator.GenerateSequenceDiagram(…)`.
The call syntax for the static methods is unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 15:08:48 -05:00

33 lines
1.4 KiB
C#

using Strata.SqlTools.SqlBreakdown.Classes;
namespace Strata.SqlTools.Markdown.Snowflake;
/// <summary>
/// Generates Mermaid diagrams for Snowflake SQL statements, including sequence diagrams
/// for statement execution flow and entity-relationship diagrams.
/// </summary>
public static class SqlStatementGenerator
{
/// <summary>
/// Generates a Mermaid sequence diagram showing Snowflake SQL statement execution flow.
/// </summary>
/// <param name="sqlBreakdown">The Snowflake SQL breakdown object.</param>
/// <param name="title">Optional title for the diagram.</param>
/// <returns>A string containing the Mermaid sequence diagram markdown.</returns>
public static string GenerateSequenceDiagram(SqlBreakdownBase sqlBreakdown, string? title = null)
{
return SqlServer.SqlStatementGenerator.GenerateSequenceDiagram(sqlBreakdown, title);
}
/// <summary>
/// Generates a Mermaid entity-relationship diagram from table names.
/// </summary>
/// <param name="tables">Collection of table names to include in the diagram.</param>
/// <param name="title">Optional title for the diagram.</param>
/// <returns>A string containing the Mermaid ER diagram markdown.</returns>
public static string GenerateEntityRelationshipDiagram(IEnumerable<string> tables, string? title = null)
{
return SqlServer.SqlStatementGenerator.GenerateEntityRelationshipDiagram(tables, title);
}
}