Skip to content

[file-diet] Split AzureDevOpsTestResultsClient.cs into focused modules #10744

Description

@github-actions

Overview

The file src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsTestResultsClient.cs has grown to 655 lines, making it harder to navigate and maintain. This task involves refactoring it into smaller, more focused files using C# partial class.

(Note: two larger files exist in the repo — Hashing/XxHashShared.cs (925 lines) and ServerMode/JsonRpc/Json/Jsonite/JsonReader.cs (691 lines) — but both are verbatim ports of external upstream code (dotnet/runtime and Alexandre Mutel's Jsonite respectively) and should not be split, since that would complicate syncing future upstream changes. This file is the largest genuinely in-house, non-vendored source file.)

Current State

  • File: src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsTestResultsClient.cs
  • Size: 655 lines
  • Language: C#
Structural Analysis

The AzureDevOpsTestResultsClient internal sealed class implements IAzureDevOpsTestResultsClient and mixes several distinct responsibilities:

  • Public API surface: CreateTestRunAsync, PublishTestResultsAsync, PublishTestResultsWithSubResultsAsync, UpdateTestResultsAsync, UpdateTestResultsWithSubResultsAsync, UploadTestResultAttachmentAsync, UploadTestRunAttachmentAsync, UpdateTestRunStateAsync.
  • HTTP transport / retry plumbing: SendAsync overloads, SendCoreAsync (timeout/retry logic), CloneAsync (request cloning for retries), ReadAsStringAsync.
  • HttpClient construction/configuration: CreateHttpClient, CreateHttpClientHandler, ShouldOptInToAutomaticDecompression.
  • URI building helpers: BuildRunsUri, BuildRunUri, BuildResultsUri, BuildResultAttachmentsUri, BuildRunAttachmentsUri, etc.
  • Request/response payload helpers: TryReadAndParsePublishedResultsAsync, TryBuildAttachmentRequest, CreateRequest.

Refactoring Strategy

Proposed File Splits

Split the class into partial class files (preserving the single logical type and its public API) grouped by responsibility:

  1. AzureDevOpsTestResultsClient.cs (retained, trimmed)

    • Contents: Class declaration, fields/constants, and the public API methods (CreateTestRunAsync, PublishTestResultsAsync, PublishTestResultsWithSubResultsAsync, UpdateTestResultsAsync, UpdateTestResultsWithSubResultsAsync, UploadTestResultAttachmentAsync, UploadTestRunAttachmentAsync, UpdateTestRunStateAsync).
    • Responsibility: Public entry points for publishing/updating test runs and results.
  2. AzureDevOpsTestResultsClient.Http.cs

    • Contents: SendAsync overloads, SendCoreAsync, CloneAsync, ReadAsStringAsync, CreateHttpClient, CreateHttpClientHandler, ShouldOptInToAutomaticDecompression.
    • Responsibility: Low-level HTTP transport, retry, and client configuration concerns.
  3. AzureDevOpsTestResultsClient.Uris.cs

    • Contents: All Build*Uri helper methods.
    • Responsibility: Centralize Azure DevOps REST endpoint URI construction.
  4. AzureDevOpsTestResultsClient.Payloads.cs

    • Contents: TryReadAndParsePublishedResultsAsync, TryBuildAttachmentRequest, CreateRequest.
    • Responsibility: Building HTTP request payloads and parsing response payloads.

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; use partial class so IAzureDevOpsTestResultsClient implementation stays intact.
  3. Update Imports: Fix all using directives per new file as needed.
  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 partial-class files
  • Each new file is under 300 lines
  • All tests pass after refactoring
  • No breaking changes to public API
  • All import paths/usings updated correctly

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 · 30.4 AIC · ⌖ 1.49 AIC · ⊞ 11.4K · [◷]( · )

  • expires on Aug 27, 2026, 7:07 PM UTC

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/automationCreated or maintained by an agentic workflow.type/tech-debtCode health, refactoring, simplification.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions