Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[file-diet] Refactor AzureDevOpsTestResultsPublisher.cs (578 lines) into focused partial-class files

Open
#11,501 0 comments 1 reaction 2 assignees View on GitHub

@Evangelink is already working on this.

Since Sep 24, 2026.

  • #11502 by @copilot-swe-agent — open

Assessment

This issue has not been assessed yet.

Description

type/automation type/tech-debt
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/IOutputDeviceDataProducer metadata properties (Uid, Version, DisplayName, Description, DataTypesConsumed).
  • Session lifecycle handling: OnTestSessionStartingAsync (~80 lines) and OnTestSessionFinishingAsync (~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 nested InProcessRetrySequence class, and DrainIncompleteInProcessRetrySequences, which together implement a self-contained algorithm for coalescing retry attempts for the same test case before publishing.
  • Dispose/IsEnabledAsync lifecycle 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:

  1. AzureDevOpsTestResultsPublisher.InProcessRetryAggregation.cs

    • Contents: ConsumeAsync, AggregateInProcessRetryAttempt, nested InProcessRetrySequence class, DrainIncompleteInProcessRetrySequences, and the related _inProcessRetrySequences / _inProcessRetryAttemptsLock fields.
    • Responsibility: Coalescing in-process test retry attempts into a single result before they are queued for publishing.
  2. AzureDevOpsTestResultsPublisher.Output.cs

    • Contents: WarnAsync, DisplayAsync, DisplayCoreAsync, TryLogWarning.
    • Responsibility: Output-device/logger interaction for warnings and diagnostic messages surfaced to the user.
  3. AzureDevOpsTestResultsPublisher.SessionLifetime.cs

    • Contents: OnTestSessionStartingAsync, OnTestSessionFinishingAsync, Dispose, IsEnabledAsync.
    • Responsibility: ITestSessionLifetimeHandler implementation — orchestrating startup, coordinated flush/finalization, and teardown of the publisher across the test session.
  4. AzureDevOpsTestResultsPublisher.cs (remaining)

    • Contents: Fields, constructors, and IDataConsumer/IOutputDeviceDataProducer metadata properties (Uid, Version, DisplayName, Description, DataTypesConsumed, CurrentRunId, RunId).
    • Responsibility: Core type definition, dependency wiring, and metadata surface.
Implementation Guidelines
  1. Preserve Behavior: All existing functionality must work identically after the split
  2. Maintain Public API: Keep exported/public symbols accessible with the same names
  3. Update Imports: Fix all import paths throughout the codebase
  4. Test After Each Split: Run the test suite after each incremental change
  5. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/testfx

All issues in microsoft/testfx

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.