Refactor CtrfReportEngine into focused partial files (#9054)#9057
Merged
Conversation
Splits the 778-line CtrfReportEngine.cs into focused partial-class files, each under 300 lines, with no public/internal API change: - CtrfReportEngine.cs - orchestration (constructor, GenerateReportAsync, GenerateReportCoreAsync) - CtrfReportEngine.FileWriter.cs - collision-safe file persistence - CtrfReportEngine.FileNaming.cs - output-path construction and sanitization - CtrfReportEngine.JsonSerializer.cs - top-level CTRF JSON document - CtrfReportEngine.JsonTestWriter.cs - per-test/attempt JSON writing - CtrfReportEngine.TestCollapsing.cs - retry-attempt collapsing and output-line helpers Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors CtrfReportEngine (CTRF report generation for Microsoft.Testing.Platform) by splitting a large single file into multiple focused partial class files, preserving existing behavior and API surface while improving navigability and maintainability.
Changes:
- Converted
CtrfReportEngineto aninternal sealed partialclass and kept orchestration inCtrfReportEngine.cs. - Extracted file naming + sanitization, file writing (collision-safe persistence), JSON serialization, per-test JSON writing, and retry-attempt collapsing/output helpers into dedicated partial files.
- Kept the CTRF JSON output structure and retry-collapsing logic intact, but moved responsibilities into smaller modules.
Show a summary per file
| File | Description |
|---|---|
| src/Platform/Microsoft.Testing.Extensions.CtrfReport/CtrfReportEngine.cs | Keeps constructor and orchestration (GenerateReportAsync / core flow), now partial. |
| src/Platform/Microsoft.Testing.Extensions.CtrfReport/CtrfReportEngine.FileWriter.cs | Contains retry/collision-safe file persistence helpers. |
| src/Platform/Microsoft.Testing.Extensions.CtrfReport/CtrfReportEngine.FileNaming.cs | Builds default file names and resolves/sanitizes templated names and environment metadata. |
| src/Platform/Microsoft.Testing.Extensions.CtrfReport/CtrfReportEngine.JsonSerializer.cs | Builds the top-level CTRF JSON document (summary, tool/environment metadata, tests array). |
| src/Platform/Microsoft.Testing.Extensions.CtrfReport/CtrfReportEngine.JsonTestWriter.cs | Writes per-test JSON, retry attempts, trait/tag/label emission logic. |
| src/Platform/Microsoft.Testing.Extensions.CtrfReport/CtrfReportEngine.TestCollapsing.cs | Collapses retry attempts per UID and writes stdout/stderr line arrays. |
Copilot's findings
- Files reviewed: 6/6 changed files
- Comments generated: 1
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.
Fixes #9054.
Splits the 778-line
CtrfReportEngine.csinto focusedpartial classfiles, each under 300 lines, with no public or internal API changes and identical behavior:CtrfReportEngine.csGenerateReportAsync,GenerateReportCoreAsync)CtrfReportEngine.FileWriter.csWriteWithRetryAsync,SplitCtrfExtension,WriteAsync)CtrfReportEngine.FileNaming.csBuildDefaultFileName,ResolveJsonFileName, TFM/OS lookup, reserved-name detection)CtrfReportEngine.JsonSerializer.csBuildCtrfJson)CtrfReportEngine.JsonTestWriter.csWriteTest,WriteRetryAttempt,HasSameKeyEarlier)CtrfReportEngine.TestCollapsing.csCollapseAttempts,WriteOutputLines,CollapsedTestResult)Validation
dotnet buildof the CtrfReport project succeeds (0 warnings, 0 errors) across net8.0/net9.0/netstandard2.0.Microsoft.Testing.Extensions.UnitTests, filter~Ctrf).Acceptance criteria