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

[duplicate-code] Extract duplicated `HasDuplicateModuleIdentity` helper from AzureDevOps and GitHubActions summary reporters

Closed Beginner friendly
#11,995 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Evangelink is already working on this.

Since Oct 18, 2026.

  • #12007 by @copilot-swe-agent — merged

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
testing-qa

Research direction

Read the two duplicate implementations in AzureDevOpsSummaryReporter.Markdown.cs and GitHubActionsSummaryReporter.Markdown.Aggregate.cs, then check the existing shared helper pattern in SharedExtensionHelpers/CiRunSummaryExitCode.cs. Move the predicate into SharedExtensionHelpers and update both call sites. Build both reporter projects and run their existing unit tests; done means the duplicate methods are removed and behavior is unchanged.

Written by the indexing model from the issue text.

Description

type/automation type/tech-debt

Summary

The private helper method HasDuplicateModuleIdentity(IReadOnlyList<CiRunSummaryModule> modules, CiRunSummaryModule module) is implemented with byte-for-byte identical logic in two separate reporter projects that both already share compiled source via src/Platform/SharedExtensionHelpers/.

Duplication Details

Pattern: Identical module-identity-disambiguation predicate
  • Severity: Medium

  • Occurrences: 2 (exact duplicate, same signature and body)

  • Locations:

    • src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsSummaryReporter.Markdown.cs (lines 547-551)
    • src/Platform/Microsoft.Testing.Extensions.GitHubActionsReport/GitHubActionsSummaryReporter.Markdown.Aggregate.cs (lines 197-201)
  • Code Sample:

    private static bool HasDuplicateModuleIdentity(IReadOnlyList<CiRunSummaryModule> modules, CiRunSummaryModule module)
        => modules.Count(candidate =>
            string.Equals(candidate.AssemblyName, module.AssemblyName, StringComparison.Ordinal)
            && string.Equals(candidate.TargetFramework, module.TargetFramework, StringComparison.Ordinal)
            && string.Equals(candidate.Architecture, module.Architecture, StringComparison.OrdinalIgnoreCase)) > 1;
    

This exact text appears identically in both files, operating on the shared CiRunSummaryModule type defined in src/Platform/SharedExtensionHelpers/CiRunSummaryModels.cs, which both .csproj files already link via <Compile Include="...SharedExtensionHelpers\CiRunSummaryModels.cs" ...>.

Impact Analysis

  • Maintainability: Any future change to the module-identity-disambiguation rule (e.g., adding a new discriminator field, changing comparison semantics) requires updating both reporters in lockstep. There is no compiler/analyzer safeguard forcing that synchronization today.
  • Bug Risk: A fix or tweak applied to one copy (e.g., in a future PR touching only the AzureDevOps or only the GitHub Actions reporter) can silently diverge from the other, producing inconsistent "attempt N, session X" disambiguation behavior between the two CI summary formats.
  • Code Bloat: Minor (5 lines), but representative of a broader pattern already being addressed in this codebase — CiRunSummaryExitCode (PR #11970) and other SharedExtensionHelpers files were introduced specifically to deduplicate logic shared by these two reporters.

Refactoring Recommendations

  1. Move HasDuplicateModuleIdentity into SharedExtensionHelpers
    • Extract common functionality to: src/Platform/SharedExtensionHelpers/CiRunSummaryModule.Identity.cs (or add as a method on CiRunSummaryModels.cs alongside the CiRunSummaryModule type it operates on, following the same pattern as CiRunSummaryExitCode.cs)
    • Make it internal static in namespace Microsoft.Testing.Extensions (matching CiRunSummaryExitCode's placement) so both linked projects pick it up without any .csproj change (both already compile every file under SharedExtensionHelpers/).
    • Update both call sites to call the shared method instead of their private copies, and delete the two private duplicates.
    • Estimated effort: ~15 minutes, very low complexity — no behavior change, pure move.
    • Benefits: Single source of truth for module-identity-disambiguation; consistent with the existing CiRunSummaryExitCode precedent in the same directory; removes the latent risk of silent divergence.

Implementation Checklist

  • Review duplication findings
  • Move HasDuplicateModuleIdentity to src/Platform/SharedExtensionHelpers/ (e.g., as part of CiRunSummaryModels.cs or a new small file)
  • Update AzureDevOpsSummaryReporter.Markdown.cs to call the shared method and delete its private copy
  • Update GitHubActionsSummaryReporter.Markdown.Aggregate.cs to call the shared method and delete its private copy
  • Build both Microsoft.Testing.Extensions.AzureDevOpsReport and Microsoft.Testing.Extensions.GitHubActionsReport projects to confirm no regressions
  • Run existing unit tests for both reporters to verify behavior is unchanged (this is a pure, behavior-preserving extraction)

Analysis Metadata

  • Analyzed Files: Recent commits touching src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/ and src/Platform/Microsoft.Testing.Extensions.GitHubActionsReport/ (commits 88788a9eb, 96ad90a8a, and related history)
  • Detection Method: Semantic code analysis (method signature/body comparison across reporter projects that already share compiled source)
  • Commit: e51893b06f6a5c6faa3a702a8e9d78cd93c35ce9

🤖 Automated content by GitHub Copilot. Generated by the Duplicate Code Detector workflow. · copilot · auto · 72.2 AIC · ⌖ 5.27 AIC · ⊞ 13.9K · [◷]( · ◷)

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/duplicate-code-detector.md@main
  • expires on Oct 19, 2026, 4:26 AM UTC
Dominant language
C#
Stars
1.1k
Forks
312
Avg merge
8h 33m
Merged PRs (30d)
411

Getting set up

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.