Refactor plan parsing, rendering, and web endpoints for maintainability - #13
Merged
Conversation
There was a problem hiding this comment.
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
PlanWorkspaceServiceand migratesHomepage plan/statement/compare orchestration to it, adding unit tests. - Extracts plan export and estimated-showplan endpoint logic into
PlanExportServiceandEstimatedShowplanApiService. - 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. |
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.
Summary
PlanWorkspaceServicebehavior.Testing