[file-diet] Refactor AzureDevOpsTestResultsPublisher.cs (578 lines) into focused partial-class files
Assessment
This issue has not been assessed yet.
Description
Overview
The file src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsTestResultsPublisher.cs has grown to 578 lines, making it harder to navigate and maintain. This task involves refactoring it into smaller, more focused files.
Current State
- File:
src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsTestResultsPublisher.cs - Size: 578 lines
- Language: C#
Structural Analysis
AzureDevOpsTestResultsPublisher is already split via the partial class convention into several sibling files (.Attachments.cs, .AttemptPublishing.cs, .Flush.cs, .ResultFactory.cs, .ResultPublishing.cs, .Utilities.cs), but the remaining core file still mixes multiple distinct concerns:
- Fields, constructors, and
IDataConsumer/IOutputDeviceDataProducermetadata properties (Uid,Version,DisplayName,Description,DataTypesConsumed). - Session lifecycle handling:
OnTestSessionStartingAsync(~80 lines) andOnTestSessionFinishingAsync(~135 lines), which contain the bulk of the file's logic — coordinating lease renewal, forced flush, attachment upload, run finalization, and warning reporting at session end. - Output/logging helpers:
WarnAsync,DisplayAsync,DisplayCoreAsync,TryLogWarning. - In-process retry aggregation:
ConsumeAsync,AggregateInProcessRetryAttempt, the nestedInProcessRetrySequenceclass, andDrainIncompleteInProcessRetrySequences, which together implement a self-contained algorithm for coalescing retry attempts for the same test case before publishing. Dispose/IsEnabledAsynclifecycle plumbing.
Refactoring Strategy
Proposed File Splits
Following the existing partial-class convention already used for this type, split the remaining logic into additional partial-class files:
-
AzureDevOpsTestResultsPublisher.InProcessRetryAggregation.cs- Contents:
ConsumeAsync,AggregateInProcessRetryAttempt, nestedInProcessRetrySequenceclass,DrainIncompleteInProcessRetrySequences, and the related_inProcessRetrySequences/_inProcessRetryAttemptsLockfields. - Responsibility: Coalescing in-process test retry attempts into a single result before they are queued for publishing.
- Contents:
-
AzureDevOpsTestResultsPublisher.Output.cs- Contents:
WarnAsync,DisplayAsync,DisplayCoreAsync,TryLogWarning. - Responsibility: Output-device/logger interaction for warnings and diagnostic messages surfaced to the user.
- Contents:
-
AzureDevOpsTestResultsPublisher.SessionLifetime.cs- Contents:
OnTestSessionStartingAsync,OnTestSessionFinishingAsync,Dispose,IsEnabledAsync. - Responsibility:
ITestSessionLifetimeHandlerimplementation — orchestrating startup, coordinated flush/finalization, and teardown of the publisher across the test session.
- Contents:
-
AzureDevOpsTestResultsPublisher.cs(remaining)- Contents: Fields, constructors, and
IDataConsumer/IOutputDeviceDataProducermetadata properties (Uid,Version,DisplayName,Description,DataTypesConsumed,CurrentRunId,RunId). - Responsibility: Core type definition, dependency wiring, and metadata surface.
- Contents: Fields, constructors, and
Implementation Guidelines
- Preserve Behavior: All existing functionality must work identically after the split
- Maintain Public API: Keep exported/public symbols accessible with the same names
- Update Imports: Fix all import paths throughout the codebase
- Test After Each Split: Run the test suite after each incremental change
- One File at a Time: Split one module at a time to make review easier
Acceptance Criteria
- Original file is split into focused modules
- Each new file is under 300 lines
- All tests pass after refactoring
- No breaking changes to public API
- All import paths updated correctly
Priority: Medium
Effort: Small
Expected Impact: Improved code navigability, easier testing, reduced merge conflicts
🤖 Automated content by GitHub Copilot. Generated by the Daily File Diet workflow. · copilot · auto · 48.4 AIC · ⌖ 5.69 AIC · ⊞ 12.1K · [◷]( · ◷)
- expires on Sep 26, 2026, 6:57 PM UTC
- Dominant language
- C#
- Stars
- 1k
- Forks
- 312
- Avg merge
- 8h 25m
- Merged PRs (30d)
- 491
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/testfx
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
agentic-workflows area/performance type/automation
Difficulty 2/5 1-3 hours Newbie friendliness 15/100
-
area/mtp needs/triage
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
area/winui
-
type/automation type/tech-debt
Difficulty 5/5 Over a week Newbie friendliness 10/100
All issues in microsoft/testfx
Similar issues
-
area-ai untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
dotnet/extensions#7783 ·
-
untriaged
Difficulty 1/5 Under an hour Newbie friendliness 88/100
dotnet/dotnet-api-docs#13095 ·
-
area-deployment area-integrations triage:bot-seen
Difficulty 2/5 Half a day Newbie friendliness 86/100
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
newrelic/newrelic-dotnet-agent#3850 · 1 comment ·
-
Needs: Triage (Functions)
Difficulty 2/5 1-3 hours Newbie friendliness 68/100