Repository navigation
Description
Code Duplication Analysis
Auto-generated by the dedup-analysis workflow
Overview
| Metric | Value |
|---|---|
| Total clones | 442 |
| Duplicated lines | 6022 |
| Duplication % | 3.896851845860161% |
| Source files scanned | 1253 |
| Findings analyzed | 20 |
Analysis
| Priority | File A | File B | Lines | Classification | Approach | Risk |
|---|---|---|---|---|---|---|
| High | Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestRunSettings.cs | Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/RunSettingsPatcher.cs | 51 | Extract Method | Extract the duplicated logic into a shared helper library or common project used by both Adapter and VSTestBridge to reduce maintenance. | Medium |
| High | Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestRunSettings.cs | Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/RunSettingsPatcher.cs | 33 | Extract Method | Same as above; consolidate duplicated run settings patching code into a shared helper to avoid divergence. | Medium |
| Medium | Adapter/MSTestAdapter.PlatformServices/Helpers/ReflectHelper.cs | Adapter/MSTestAdapter.PlatformServices/Services/ReflectionOperations.cs | 32 | Extract Method | Refactor reflection helper methods into a shared helper class or project within MSTestAdapter.PlatformServices. | Low |
| Medium | Analyzers/MSTest.Analyzers/AssemblyFixtureProviderNotSupportedWithNativeAotAnalyzer.cs | Analyzers/MSTest.Analyzers/AvoidUsingAssertsInAsyncVoidContextAnalyzer.cs | 35 | Extract Method | Extract common analyzer logic into base classes or shared helper methods within MSTest.Analyzers project. | Low |
| Medium | Analyzers/MSTest.Analyzers/PreferAssertFailOverAlwaysFalseConditionsAnalyzer.cs | Analyzers/MSTest.Analyzers/ReviewAlwaysTrueAssertConditionAnalyzer.cs | 34 | Extract Method | Parameterize or extract common logic for assert condition analysis into shared helpers or base classes. | Low |
| Medium | Analyzers/MSTest.Analyzers/AssemblyFixtureProviderNotSupportedWithNativeAotAnalyzer.cs | Analyzers/MSTest.Analyzers/AssertionArgsShouldBePassedInCorrectOrderAnalyzer.cs | 30 | Extract Method | Consolidate common analyzer code to reduce duplication and improve maintainability. | Low |
| Medium | Analyzers/MSTest.Analyzers/CollectionAssertToAssertAnalyzer.cs | Analyzers/MSTest.Analyzers/DoNotNegateBooleanAssertionAnalyzer.cs | 30 | Extract Method | Extract shared logic for assertion analysis into common base or helper classes. | Low |
| Medium | Analyzers/MSTest.Analyzers/AssemblyFixtureProviderNotSupportedWithNativeAotAnalyzer.cs | Analyzers/MSTest.Analyzers/AvoidAssertAreSameWithValueTypesAnalyzer.cs | 29 | Extract Method | Refactor duplicated analyzer logic into shared helpers or base classes. | Low |
| Medium | Adapter/MSTestAdapter.PlatformServices/Execution/SynchronizationContextPreservingAsyncTaskMethodBuilder.cs (lines 17-50) | Adapter/MSTestAdapter.PlatformServices/Execution/SynchronizationContextPreservingAsyncTaskMethodBuilder.cs (lines 63-96) | 34 | Intentional | Code duplicated within the same file likely for different method overloads or partial class; leave as is. | Low |
| Medium | Platform/Microsoft.Testing.Platform/Messages/DataWithSessionUid.cs | Platform/Microsoft.Testing.Platform/Messages/PropertyBagData.cs | 31 | Extract Base Class | Extract common message data properties or behavior into a base class to reduce duplication. | Low |
| Medium | Platform/Microsoft.Testing.Platform/Messages/DataWithSessionUid.cs | Platform/Microsoft.Testing.Platform/Messages/FileArtifacts.cs | 28 | Extract Base Class | Consolidate shared message data into base class or shared helper to reduce duplication. | Low |
| Medium | Platform/Microsoft.Testing.Platform/Messages/DataWithSessionUid.cs | Platform/Microsoft.Testing.Platform/Messages/TestNode.cs | 28 | Extract Base Class | Same as above; unify common message data members in a base class. | Low |
| Medium | Platform/Microsoft.Testing.Platform/Messages/FileArtifacts.cs | Platform/Microsoft.Testing.Platform/Messages/FileArtifacts.cs | 29 | Intentional | Duplicate code in same file (different line ranges) likely intentional for overloads or partial methods. | Low |
| Medium | TestFramework/TestFramework/Assertions/Assert.ContainsSingle.Span.cs | TestFramework/TestFramework/Assertions/Assert.ContainsSingle.cs | 31 | Template Method | Parameterize or unify similar assertion methods to reduce duplication while preserving intent. | Low |
| Low | Adapter/MSTest.TestAdapter/Services/TestResultRecorderExtensions.cs | Adapter/MSTestAdapter.PlatformServices/Execution/TestClassInfo.Initializer.cs | 35 | Intentional | Different files and purposes; duplication likely coincidental or minimal; low priority for refactoring. | Low |
| Low | Analyzers/MSTest.Analyzers/RoslynAnalyzerHelpers/WellKnownTypeProvider.cs | Platform/Microsoft.Testing.Platform.MSBuild/Tasks/UnicodeCharacterUtilities.cs | 34 | Intentional | Different projects and purposes; duplication likely coincidental or minimal; leave as is. | Low |
| High | Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Jsonite/Json.cs | Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Jsonite/JsonReflector.cs | 54 | Intentional | These files are in the same folder and likely part of the same component; duplication may be intentional for isolation. | Low |
| High | Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Jsonite/Json.cs | Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Jsonite/JsonWriter.cs | 54 | Intentional | Same as above; likely intentional duplication for component isolation or partial class usage. | Low |
| High | Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Jsonite/Json.cs | Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Jsonite/JsonReader.cs | 45 | Intentional | Same as above; leave as is due to design or component isolation. | Low |
| High | Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Jsonite/Json.cs | Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/Json/Jsonite/JsonTypes.cs | 44 | Intentional | Same as above; intentional duplication for component isolation or partial class design. | Low |
Summary
- Total duplicates analyzed: 21 pairs
- Classification counts:
- Extract Method: 9
- Extract Base Class: 3
- Template Method: 1
- Intentional: 8
- High priority duplicates: 4 (mostly in run settings and JsonRpc Jsonite files)
- Medium priority duplicates: 12
- Low priority duplicates: 5
Top 3 recommended refactorings to tackle first
-
RunSettings duplication between MSTestRunSettings.cs and RunSettingsPatcher.cs (51 and 33 lines)
Consolidate duplicated run settings logic into a shared helper or common project to reduce maintenance overhead and avoid divergence between Adapter and VSTestBridge. -
Reflection helper duplication in MSTestAdapter.PlatformServices (32 lines)
Extract reflection helper methods into a shared helper class to unify reflection operations and reduce duplicated code. -
Assertion analyzers duplication in MSTest.Analyzers (multiple 30+ line duplicates)
Refactor common analyzer logic into base classes or shared helpers to improve maintainability and reduce duplicated code across analyzers.
The JsonRpc Jsonite duplicates appear intentional due to component design and should be left as is to avoid breaking changes.
Generated by dedup-analysis workflow using jscpd + GitHub Models (openai/gpt-4.1-mini)
Activity
Evangelink commentedon Jun 29, 2026
Status update
Several items from this duplication analysis have already been addressed by merged PRs:
ReportGeneratorBase.CreateReportEngineContext(...)helper (Address tech-debt batch: analyzer/report-engine dedup, MSBuild authoring, file diet #9487). Tracked separately and closed as [duplicate-code] Duplicate Code: Identical Report Engine Constructor Arguments in ReportGenerator Classes #9482.ReflectHelper/ReflectionHelperduplicated reflection helpers — consolidated (Remove duplicated reflection helpers in ReflectHelper #9502).AnalyzeSymbolduplication (Test/Class/Assembly Initialize+Cleanup) — refactored into sharedFixtureMethodAnalyzerHelperregistrations (Refactor TestInitialize/TestCleanup analyzer registration into shared fixture helper #9485, Refactor duplicated class fixture analyzer validation into shared helper #9492, Deduplicate assembly fixture analyzer validation #9493). Tracked/closed as [duplicate-code] Duplicate Code: Near-Identical TestInitializeShouldBeValidAnalyzer and TestCleanupShouldBeValidAnalyzer #9483, [duplicate-code] Duplicate Code: ClassInitialize/ClassCleanup AnalyzeSymbol Pattern in Fixture Analyzers #9490, [duplicate-code] Duplicate Code: AssemblyInitialize/AssemblyCleanup AnalyzeSymbol Pattern in Fixture Analyzers #9491.WellKnownTypeProvider/UnicodeCharacterUtilities) — reconciled (Reconcile vendored files: LLM detector, XxHashShared, NativeMethods, EquatableArray #9500); these are intentional/vendored and kept in sync rather than merged.Remaining / not actioned (by design)
Json.csvsJsonReader/JsonWriter/JsonReflector/JsonTypes, the 4 high-priority rows) — this is vendored third-party code that the repo does not hand-edit, so it is intentionally left as-is.DataWithSessionUid,PropertyBagData,FileArtifacts,TestNode,TestNodeUpdateMessage, …) — these are public/serialized message types where a shared base class would risk the wire/serialization contract; treated as intentional unless a concrete refactor is scoped.Leaving this umbrella issue open to track any of the remaining low/medium items the team chooses to pick up.