Skip to content

Refactor plan parsing, rendering, and web endpoints for maintainability - #13

Merged
MasayukiOzawa merged 1 commit into
masterfrom
refactor/maintainability
Jun 21, 2026
Merged

Refactor plan parsing, rendering, and web endpoints for maintainability#13
MasayukiOzawa merged 1 commit into
masterfrom
refactor/maintainability

Conversation

@MasayukiOzawa

Copy link
Copy Markdown
Owner

Summary

  • Split parsing and XML traversal logic into smaller focused components for easier maintenance.
  • Refined plan rendering services to isolate layout, critical path, and SVG generation concerns.
  • Simplified web app wiring and endpoint/services around estimated showplan handling, export, and workspace state.
  • Added/updated tests around PlanWorkspaceService behavior.

Testing

  • Updated unit coverage for workspace state handling.
  • Not run (not requested).

Copilot AI review requested due to automatic review settings June 21, 2026 08:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the showplan parsing/rendering pipeline and the web layer by extracting endpoint and UI workspace logic into focused helper/services, aiming to improve maintainability and reduce duplicated orchestration code in pages/endpoints.

Changes:

  • Introduces PlanWorkspaceService and migrates Home page plan/statement/compare orchestration to it, adding unit tests.
  • Extracts plan export and estimated-showplan endpoint logic into PlanExportService and EstimatedShowplanApiService.
  • Splits previously-inline parser/rendering helpers into dedicated components (XML loading/schema version resolution, attribute-path matching, critical-path finding, SVG edge path building).

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/MSSQLPlanViewer.Core.Tests/PlanWorkspaceServiceTests.cs Adds coverage for PlanWorkspaceService plan initialization, statement selection, and compare selection.
src/MSSQLPlanViewer.Web/State/PlanWorkspaceService.cs New service encapsulating loaded-plan workspace state transitions (select statement, refresh layout, compare selection).
src/MSSQLPlanViewer.Web/Program.cs Registers new web-layer services in DI.
src/MSSQLPlanViewer.Web/PlanExportService.cs New service encapsulating export request validation, statement resolution, and file responses.
src/MSSQLPlanViewer.Web/PlanExportEndpoints.cs Refactors endpoints to delegate export execution to PlanExportService and centralizes OpenAPI helpers usage.
src/MSSQLPlanViewer.Web/OpenApiDocumentationHelpers.cs New shared OpenAPI request-body/schema documentation helper methods.
src/MSSQLPlanViewer.Web/EstimatedShowplanEndpoints.cs Refactors endpoint to delegate execution to EstimatedShowplanApiService and centralizes OpenAPI helpers usage.
src/MSSQLPlanViewer.Web/EstimatedShowplanApiService.cs New service encapsulating estimated-showplan validation, provider call, parsing, and response shaping.
src/MSSQLPlanViewer.Web/Components/Pages/Home.razor.cs Simplifies page orchestration by delegating to PlanWorkspaceService.
src/MSSQLPlanViewer.Web/Components/Pages/Home.razor Updates DI usage to inject PlanWorkspaceService instead of multiple lower-level services.
src/MSSQLPlanViewer.Core/Rendering/PlanGraphSvgRenderer.cs Delegates SVG edge-path generation to new builder helper.
src/MSSQLPlanViewer.Core/Rendering/PlanGraphSvgPathBuilder.cs New helper for consistent SVG path construction (horizontal vs vertical).
src/MSSQLPlanViewer.Core/Rendering/PlanGraphLayoutService.cs Delegates critical path computation to a dedicated helper.
src/MSSQLPlanViewer.Core/Rendering/PlanGraphCriticalPathFinder.cs New helper encapsulating critical-path tracing logic.
src/MSSQLPlanViewer.Core/Parsing/ShowplanXmlElement.cs New XML helper for element name/attribute retrieval.
src/MSSQLPlanViewer.Core/Parsing/ShowplanXmlDocumentLoader.cs New XML loader enforcing safe reader settings and document size limits.
src/MSSQLPlanViewer.Core/Parsing/ShowplanXmlAttributePathMatcher.cs New helper encapsulating attribute-path wildcard matching logic.
src/MSSQLPlanViewer.Core/Parsing/ShowplanSchemaVersionResolver.cs New helper mapping showplan XML namespace URIs to schema versions.
src/MSSQLPlanViewer.Core/Parsing/ShowplanParser.cs Updates parser to use new loader/schema resolver and new attribute-path matcher.

Comment thread tests/MSSQLPlanViewer.Core.Tests/PlanWorkspaceServiceTests.cs
Comment thread src/MSSQLPlanViewer.Core/Parsing/ShowplanParser.cs
@MasayukiOzawa
MasayukiOzawa merged commit d4ae9a7 into master Jun 21, 2026
1 check passed
@MasayukiOzawa
MasayukiOzawa deleted the refactor/maintainability branch June 21, 2026 09:01
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