Skip to content

Split PlanAnalyzer.cs into partial classes#329

Merged
erikdarlingdata merged 37 commits into
devfrom
feature/split-plananalyzer
May 13, 2026
Merged

Split PlanAnalyzer.cs into partial classes#329
erikdarlingdata merged 37 commits into
devfrom
feature/split-plananalyzer

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

Move-only refactor of PlanViewer.Core/Services/PlanAnalyzer.cs (2,238 lines) into 5 topical partial-class files.

File sizes

File Lines Contents
PlanAnalyzer.cs (main) 115 Regex constants, LegacyWarningTypes / RuleWarningTypes / WarningTypeToRule dictionaries, static ctor, public Analyze(), nested ScanImpact record
.Statement.cs 439 AnalyzeStatement — statement-level rules (~440-line method)
.Node.cs 777 AnalyzeNodeTree + AnalyzeNode — operator-level rules
.Detection.cs 248 Predicate/pattern helpers (NOT IN, anti-semi-join, rowstore scan, probe-only, non-SARGable, OR-expansion, adaptive join)
.Timing.cs 345 Operator CPU/elapsed helpers (GetOperatorOwnElapsedMs, GetPerThreadOwnElapsed, GetEffectiveChildCpuMs, etc.) + BuildScanImpactDetails + memory consumers
.Helpers.cs 275 Severity overrides, wait labels, scan/spill helpers, FormatNodeRef, IdentifyRowGoalCause, Truncate

Behavior

  • Move-only. No method bodies were modified.
  • Class made partial (was public static class).
  • internal members (GetOperatorOwnElapsedMs, GetOperatorMaxThreadOwnCpuMs) remain internal; BenefitScorer still calls them.
  • PlanViewer.Web.csproj updated to link the new partial files (Web links Core source files directly, not via project reference).

Test plan

  • dotnet build PlanViewer.sln — 0 errors, 0 warnings (all 5 projects: Core, App, Cli, Tests, Web)
  • dotnet test tests/PlanViewer.Core.Tests — analyzer test suite still passes
  • Load a plan in the app — warnings/critical badges show as before
  • Web/Blazor build — produces same WASM output

🤖 Generated with Claude Code

erikdarlingdata and others added 30 commits April 7, 2026 11:43
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Uses the Darling Data barbell logo as hero image when shared on
social media. Also adds meta description for SEO.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add Open Graph meta tags for social sharing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merge dev: HTML export for plan analysis (#182)
This reason means something in the query blocks parallelism (scalar UDFs,
table variable inserts, etc.) — that's worth a Warning, not Info.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix Rule 3: CouldNotGenerateValidParallelPlan stays Warning
Adds human-readable messages for all 25 known reasons. Severity:
- Warning: actionable reasons (UDFs, cursors, table variables, remote
  queries, trace flags, hints, DML OUTPUT, writeback variables)
- Info: passive/environmental (cost below threshold, edition limits,
  memory-optimized tables, upgrade mode, index build edge cases)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Expand Rule 3 to cover all NonParallelPlanReason values
Merge dev: plan sharing and export (#182)
Merge dev to main (v1.4.3 + logo fix)
Merge dev: HTTPS plan sharing API
Release: issue #178 round 3 feedback (items 17-25)
Release v1.5.0 — maximum benefit scoring
Release: analytics for Plan Analyzer web app
Merge dev to main — Joe #215 feedback through b1/b7
Release v1.7.0 — wait stats as warnings
Release v1.7.1 — render benefit % and actionable fix
Release v1.7.2 — operator self-time fix + decimal benefit %
Release v1.7.3 — visible web viewer version
Release v1.7.4 — external-wait formula + CPU:Elapsed adjustment
erikdarlingdata and others added 7 commits April 22, 2026 13:21
Release v1.7.6 — C1 memory color + C4 compile time + C8 expensive-op + C9 columnstore
Release v1.7.7 — D3 content strip + legacy marker + drop Rule 21
Release v1.7.8 — batch-mode pipelined self-time (#215 D1)
Release v1.8.0 — Joe feedback E1-E12 batch
Move-only refactor; no behavior changes. PlanAnalyzer.cs (2,238 lines)
split into 5 partials:

  Statement   (439) - AnalyzeStatement (statement-level rules)
  Node        (777) - AnalyzeNodeTree + AnalyzeNode (operator rules)
  Detection   (248) - predicate/pattern helpers (HasNotIn, IsAntiSemi,
                      IsRowstoreScan, IsProbeOnly, DetectNonSargable,
                      IsOrExpansionChain, HasAdaptiveJoin, ...)
  Timing      (345) - operator CPU/elapsed helpers + ScanImpact + memory
  Helpers     (275) - severity overrides, wait labels, format, truncate

Main file now 115 lines — class declaration, regex constants, static
dictionaries (RuleWarningTypes/WarningTypeToRule), static ctor, the
public Analyze() entry point, and the ScanImpact record.

PlanViewer.Web.csproj updated to link the new partial files.

Build clean: 0 errors, 0 warnings on PlanViewer.sln.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata changed the base branch from main to dev May 13, 2026 03:16
@erikdarlingdata erikdarlingdata merged commit d8c14d1 into dev May 13, 2026
3 of 4 checks passed
@erikdarlingdata erikdarlingdata deleted the feature/split-plananalyzer branch May 13, 2026 03: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.

1 participant