Overview
The file src/Platform/SharedExtensionHelpers/CiRunSummaryAggregation.cs has grown to 834 lines, mixing several distinct concerns: data models, coverage summary computation/rendering, aggregation logic, and fragment file I/O. This makes it harder to navigate and maintain.
(Note: the repository's single largest source file, src/Platform/Microsoft.Testing.Extensions.TrxReport/Hashing/XxHashShared.cs at 925 lines, is explicitly a verbatim port of dotnet/runtime's XxHashShared.cs and should not be restructured, since that would break the ability to diff/sync against upstream. This issue targets the next-largest file that is a genuine internal implementation.)
Current State
- File:
src/Platform/SharedExtensionHelpers/CiRunSummaryAggregation.cs
- Size: 834 lines
- Language: C#
Structural Analysis
The file currently contains:
- Plain DTO/model classes:
CiRunSummaryModule, CiRunSummaryTest, CiRunSummaryFailingClass, CiCoverageSummaryData, CiCoverageMetric, CiCoverageThreshold, CiRunSummaryAggregate, CiRunSummaryFragment.
CiCoverageSummary (static class, ~130 lines) — coverage aggregation and Markdown rendering (AppendMarkdown).
CiRunSummaryAggregation (static partial class, ~390 lines) — the core logic: CreateModule, WriteFragmentAsync, ValidateModule, private helpers WriteTextAsync/WriteAtomicAsync for atomic fragment file writes, plus the nested CiRunSummaryJsonContext JSON source-generation context.
Refactoring Strategy
Proposed File Splits
-
CiRunSummaryModels.cs
- Contents:
CiRunSummaryModule, CiRunSummaryTest, CiRunSummaryFailingClass, CiCoverageSummaryData, CiCoverageMetric, CiCoverageThreshold, CiRunSummaryAggregate, CiRunSummaryFragment
- Responsibility: Pure data-transfer objects with no behavior, used across the aggregation pipeline.
-
CiCoverageSummary.cs
- Contents:
CiCoverageSummary static class (Aggregate, AppendMarkdown, and related private helpers)
- Responsibility: Coverage-specific aggregation and Markdown report rendering, isolated from run/test summary logic.
-
CiRunSummaryAggregation.cs (trimmed)
- Contents:
CiRunSummaryAggregation partial class — CreateModule, WriteFragmentAsync, ValidateModule
- Responsibility: Core orchestration of building and validating a module summary from test records.
-
CiRunSummaryFragmentIo.cs
- Contents:
WriteTextAsync, WriteAtomicAsync (as another partial of CiRunSummaryAggregation, or a small internal helper class), plus CiRunSummaryJsonContext
- Responsibility: Atomic file I/O for writing fragment JSON to disk, decoupled from aggregation logic.
Implementation Guidelines
- Preserve Behavior: All existing functionality must work identically after the split.
- Maintain Public API: Keep exported/public and internal symbols accessible with the same names and namespace (
Microsoft.Testing.Extensions).
- Update Imports: Fix all import paths/usages throughout the codebase that reference these types.
- Test After Each Split: Run the relevant unit/integration test suite after each incremental change.
- One File at a Time: Split one module at a time to make review easier — start with the DTOs (lowest risk), then coverage summary, then fragment I/O.
Acceptance Criteria
Priority: Medium
Effort: Medium
Expected Impact: Improved code navigability, easier testing, reduced merge conflicts
🤖 Automated content by GitHub Copilot. Generated by the Daily File Diet workflow. · auto · 32.6 AIC · ⌖ 2.86 AIC · ⊞ 11.4K · [◷]( · ◷)
Overview
The file
src/Platform/SharedExtensionHelpers/CiRunSummaryAggregation.cshas grown to 834 lines, mixing several distinct concerns: data models, coverage summary computation/rendering, aggregation logic, and fragment file I/O. This makes it harder to navigate and maintain.(Note: the repository's single largest source file,
src/Platform/Microsoft.Testing.Extensions.TrxReport/Hashing/XxHashShared.csat 925 lines, is explicitly a verbatim port ofdotnet/runtime'sXxHashShared.csand should not be restructured, since that would break the ability to diff/sync against upstream. This issue targets the next-largest file that is a genuine internal implementation.)Current State
src/Platform/SharedExtensionHelpers/CiRunSummaryAggregation.csStructural Analysis
The file currently contains:
CiRunSummaryModule,CiRunSummaryTest,CiRunSummaryFailingClass,CiCoverageSummaryData,CiCoverageMetric,CiCoverageThreshold,CiRunSummaryAggregate,CiRunSummaryFragment.CiCoverageSummary(static class, ~130 lines) — coverage aggregation and Markdown rendering (AppendMarkdown).CiRunSummaryAggregation(static partial class, ~390 lines) — the core logic:CreateModule,WriteFragmentAsync,ValidateModule, private helpersWriteTextAsync/WriteAtomicAsyncfor atomic fragment file writes, plus the nestedCiRunSummaryJsonContextJSON source-generation context.Refactoring Strategy
Proposed File Splits
CiRunSummaryModels.csCiRunSummaryModule,CiRunSummaryTest,CiRunSummaryFailingClass,CiCoverageSummaryData,CiCoverageMetric,CiCoverageThreshold,CiRunSummaryAggregate,CiRunSummaryFragmentCiCoverageSummary.csCiCoverageSummarystatic class (Aggregate,AppendMarkdown, and related private helpers)CiRunSummaryAggregation.cs(trimmed)CiRunSummaryAggregationpartial class —CreateModule,WriteFragmentAsync,ValidateModuleCiRunSummaryFragmentIo.csWriteTextAsync,WriteAtomicAsync(as another partial ofCiRunSummaryAggregation, or a small internal helper class), plusCiRunSummaryJsonContextImplementation Guidelines
Microsoft.Testing.Extensions).Acceptance Criteria
Priority: Medium
Effort: Medium
Expected Impact: Improved code navigability, easier testing, reduced merge conflicts